google / traceur-compiler

Traceur is a JavaScript.next-to-JavaScript-of-today compiler
Apache License 2.0
8.17k stars 580 forks source link

Arrow functions need various static syntax errors #214

Open arv opened 11 years ago

arv commented 11 years ago

Original author: dome...@domenicdenicola.com (March 04, 2013 05:57:28)

The following should be syntax errors but are not:

(foo) => { var foo; } (foo) => { let foo; } (foo) => { const foo; } (foo, ...foo) => { } (foo, foo = 5) => { } (eval) => { } (arguments) => { } (eval, ...foo) => { } (arguments, ...foo) => { }

Note that this should not be a syntax error:

(foo, ...bar) => { var foo; }

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=211

arv commented 11 years ago

From arv@chromium.org on March 05, 2013 17:07:56 How can

(foo) => { var foo; }

and

(foo, ...bar) => { var foo; }

be different in this regard? Can you point out where in the spec this difference occurs?

arv commented 11 years ago

From domenic....@lab49.com on March 05, 2013 17:17:37

It is a Syntax Error if IsSimpleParameterList of ArrowParameters is true and any element of the BoundNames of ArrowParameters also occurs in the VarDeclaredNames of ConciseBody.

For (foo) => { var foo; }, IsSimpleParameterList is false, whereas for (foo, ...bar) => { var foo; } it is true.