(x) => {foo: bar}

Brendan Eich brendan at mozilla.org
Wed Jan 7 13:23:40 PST 2015

Allen Wirfs-Brock wrote:
> On Jan 6, 2015, at 5:34 PM, Gary Guo wrote:
>> I found that even without shorthand, the object literal can still be 
>> ambiguous with block.
> Yes, but not in the context of a ConciseBody of an ArrowFunction.
> The grammar for ConciseBody 
> (http://people.mozilla.org/~jorendorff/es6-draft.html#sec-arrow-function-definitions 
> <http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-arrow-function-definitions> 
> ) ensures that there is no ambiguity. If a ConciseBody starts with a { 
> then it must parse as either a well-formed bracketed FunctionBody or 
> as a syntax error.
> There is no guessing. { means statements follow rather than an expression.

Indeed. Perhaps Gary meant less formal ambiguity, as Caitlin did earlier 
in thread -- in which case we could future-proof or perhaps just help 
people by proscribing { L: 42 } from being parsed as a ConciseBody. I'm 
curious to know what you think about this idea. It seems best done with 
parametric productions, but I haven't worked it out yet.


More information about the es-discuss mailing list