tc39 / proposal-grouped-and-auto-accessors

Grouped Accessors and Auto-Accessors for ECMAScript
https://tc39.es/proposal-grouped-and-auto-accessors
MIT License
57 stars 5 forks source link

Ambiguous syntax with class static block #1

Closed JLHwung closed 4 years ago

JLHwung commented 4 years ago
class C {
  static {
    get;
    set;
  }
}

can be i) a static block including two expression statements or ii) an auto accessors named as "static"

Ref: https://github.com/tc39/proposal-class-static-block

rbuckton commented 4 years ago

I'm aware, as I'm the champion of both proposals. I've mentioned it in the slides for the upcoming meeting. The conflict is the same as constructor, and is resolvable by allowing ["static"] { get; set; } to mean the property, just as we do for constructor.

JLHwung commented 4 years ago

The conflict is the same as constructor

I don't follow. A class can not have constructor a field name so class { constructor } is already invalid. But static is allowed.

I've mentioned it in the slides for the upcoming meeting.

Ah I see, just checked out the slides. Will provide more feedback later.

rbuckton commented 4 years ago

What I mean with constructor is that you can define a prototype method named constructor using a computed property name that differs from the class constructor:

image