This commit is contained in:
Fábio Santos
2016-03-27 12:21:39 +01:00
parent 6d2f77c180
commit 6702cae918
2 changed files with 15 additions and 3 deletions

View File

@@ -979,11 +979,12 @@ function parse($TEXT, options) {
init =
is("keyword", "var") ? (next(), var_(true)) :
is("keyword", "let") ? (next(), let_(true)) :
is("keyword", "const") ? (next(), const_(true)) :
expression(true, true);
var is_in = is("operator", "in");
var is_of = is("name", "of");
if (is_in || is_of) {
if ((init instanceof AST_Var || init instanceof AST_Let) &&
if ((init instanceof AST_Definitions) &&
init.definitions.length > 1)
croak("Only one variable declaration allowed in for..in loop");
next();
@@ -1012,7 +1013,7 @@ function parse($TEXT, options) {
};
function for_of(init) {
var lhs = init instanceof AST_Var ? init.definitions[0].name : null;
var lhs = init instanceof AST_Definitions ? init.definitions[0].name : null;
var obj = expression(true);
expect(")");
return new AST_ForOf({
@@ -1024,7 +1025,7 @@ function parse($TEXT, options) {
};
function for_in(init) {
var lhs = init instanceof AST_Var ? init.definitions[0].name : null;
var lhs = init instanceof AST_Definitions ? init.definitions[0].name : null;
var obj = expression(true);
expect(")");
return new AST_ForIn({