tc39 / proposal-class-public-fields

Stage 2 proposal for public class fields in ECMAScript
https://tc39.github.io/proposal-class-public-fields/
487 stars 25 forks source link

Grammar & computed properties #22

Closed bathos closed 8 years ago

bathos commented 8 years ago

Does the spec have a grammar specification under development? It seems like the implied grammar, especially with decorators in the mix, has issues that no amount of lookaheads could disambiguate:

class Derp {
    @foo [bar] = baz = derp * derpGen() {}
}

Did the decorator foo [bar] = baz = derp decorate a generator method named derpGen?

Did the decorator foo decorate the property [bar], whose value was baz, and which was followed by a generator method named derpGen?

Did the decorator foo decorate the property [bar], whose value was baz = derp * derpGen(), and which was followed by a syntax error?

This stuff is tricky, and I may just be overlooking something, but it seems as if the grammar might need to either be linebreak sensitive or perhaps mandate semicolons (which would be a little weird, since these aren't statements).

bathos commented 8 years ago

(Or -- I think using a colon instead of an equals sign would permit a cover grammar to be employed to disambiguate these sorts of issues, not to mention it would remain consonant with object literal properties, which currently share most of class body's grammar).

michaelficarra commented 8 years ago

The expressions are terminated by semicolons. See the grammar in README.md.

bathos commented 8 years ago

Sorry, I missed the bit I was looking for (the EBNF block).