tc39 / proposal-optional-chaining

https://tc39.github.io/proposal-optional-chaining/
4.94k stars 75 forks source link

Should this be valid code? #89

Closed leobalter closed 4 years ago

leobalter commented 5 years ago

new new class {}()?.constructor?.(); (equivalent to new new class {}().constructor();)

When reading the proposed syntax grammar, this seems correct, but it's one of the few errors I found when parsing with Babel.

Is that an error from Babel or the actual code?

claudepache commented 5 years ago

new new class {}()?.constructor?.(); is equivalent to new FOO?.constructor?.(), which should be a syntax error. Indeed, we don’t support “optional new”, my main reason being that the expected complication of the grammar largely outweighs the (lack of) use cases. See #22.

claudepache commented 4 years ago

Closing per housekeeping.