Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upsloppy-mode let more incompatible than spec lets on (due to automatic semi-colon insertion) #259
Comments
saurik
changed the title from
loose-mode let more incompatible than spec lets on (due to automatic semi-colon insertion)
to
sloppy-mode let more incompatible than spec lets on (due to automatic semi-colon insertion)
Dec 16, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@saurik what do you think is the solution? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bterlson
Jan 16, 2016
Member
This is a great catch. Right thing to do is document in Annex E:
13.2: In ECMAScript 2015, a |StatementList| beginning with the token
letfollowed by the input elements |LineTerminator| |Identifier| is the start of a |LexicalDeclaration|. In previous editions, automatic semicolon insertion would always insert a semicolon before the |Identifier| input element.
|
This is a great catch. Right thing to do is document in Annex E:
|
saurik commentedDec 16, 2015
In ES3/5, the code
x=true;eval("var let;let\nx=false");xevaluates tofalse, while in ES6 the same code evaluates totrue, as in earlier versions of ECMAScript automatic-semicolon insertion intervenes and breaks what is now a LexicalDeclaration into two separate ExpressionStatements. This seems like something that should be documented in Annex E.FWIW, I can see that 13.5 under Annex E tries to talk about the case of a StatementListItem which begins with "let [", but the incompatibility is actually more pervasive (though likely harmless). Also, I will point out that I can actually see someone formatting their (ECMAScript 6) code in an ambiguous way: putting variables on their own lines after the let, such as "let\n\tx=0,\n\ty=1".
Legacy ECMAScript:
ECMAScript 2015: