tc39/proposal-decorators

Clarification. Can auto-accessors be redeclared?

lpardosixtosMs opened this issue · 2 comments

I'm implementing the proposal in V8 and I'd like to clarify if public auto-accessors can be redeclared.

Step 5 of the second part of this section of the draft spec creates a new Private Name whose description is the concatenation of the field's readable name and the "accessor storage" string. Since this is a new Private Name and not one taken from the private env names list, I conclude that it wouldn't collide with other private names when calling PrivateFieldAdd on it; and as a consequence, the following snippet is valid JavaScript:

class C {
  accessor x = 1;
  accessor x = 2;
}

Is this the intended behavior?

Yes, this is the intended behavior, it should work like any other public element in most aspects, so redeclarations are allowed and overwrite the previous declaration fully. This also prevents something like a subclass somehow colliding with a parent class.

Thanks for the quick response!