From fd79ac58798bdb52e918639494f7d39353484dc3 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Mon, 27 Oct 2014 02:20:23 +0200 Subject: [PATCH] Move comprehension support under `ecmaVersion: 7` as per spec. --- acorn.js | 4 ++-- test/tests-harmony.js | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/acorn.js b/acorn.js index 4bcb199a42..a36b5dac1a 100644 --- a/acorn.js +++ b/acorn.js @@ -2024,7 +2024,7 @@ var tokStartLoc1 = tokStartLoc, tokStart1 = tokStart, val, exprList; next(); // check whether this is generator comprehension or regular expression - if (options.ecmaVersion >= 6 && tokType === _for) { + if (options.ecmaVersion >= 7 && tokType === _for) { val = parseComprehension(startNodeAt(start), true); } else { var oldParenL = ++metParenL; @@ -2061,7 +2061,7 @@ var node = startNode(); next(); // check whether this is array comprehension or regular array - if (options.ecmaVersion >= 6 && tokType === _for) { + if (options.ecmaVersion >= 7 && tokType === _for) { return parseComprehension(node, false); } node.elements = parseExprList(_bracketR, true, true); diff --git a/test/tests-harmony.js b/test/tests-harmony.js index 1a883ee051..66a802be25 100644 --- a/test/tests-harmony.js +++ b/test/tests-harmony.js @@ -3577,7 +3577,7 @@ test("[for (x of array) x]", { end: {line: 1, column: 20} } }, { - ecmaVersion: 6, + ecmaVersion: 7, ranges: true, locations: true }); @@ -3699,7 +3699,7 @@ test("[for (x of array) for (y of array2) if (x === test) x]", { end: {line: 1, column: 54} } }, { - ecmaVersion: 6, + ecmaVersion: 7, ranges: true, locations: true }); @@ -3821,7 +3821,7 @@ test("(for (x of array) for (y of array2) if (x === test) x)", { end: {line: 1, column: 54} } }, { - ecmaVersion: 6, + ecmaVersion: 7, ranges: true, locations: true }); @@ -4025,7 +4025,7 @@ test("[for ([,x] of array) for ({[start.x]: x, [start.y]: y} of array2) x]", { end: {line: 1, column: 68} } }, { - ecmaVersion: 6, + ecmaVersion: 7, ranges: true, locations: true }); @@ -15127,17 +15127,17 @@ testFail("`hello ${10;test`", "Unexpected token (1:11)", {ecmaVersion: 6}); testFail("function a() 1 // expression closure is not supported", "Unexpected token (1:13)", {ecmaVersion: 6}); -testFail("[for (let x of []) x]", "Unexpected token (1:6)", {ecmaVersion: 6}); +testFail("[for (let x of []) x]", "Unexpected token (1:6)", {ecmaVersion: 7}); -testFail("[for (const x of []) x]", "Unexpected token (1:6)", {ecmaVersion: 6}); +testFail("[for (const x of []) x]", "Unexpected token (1:6)", {ecmaVersion: 7}); -testFail("[for (var x of []) x]", "Unexpected token (1:6)", {ecmaVersion: 6}); +testFail("[for (var x of []) x]", "Unexpected token (1:6)", {ecmaVersion: 7}); -testFail("[for (a in []) x] // (a,b) ", "Unexpected token (1:8)", {ecmaVersion: 6}); +testFail("[for (a in []) x] // (a,b) ", "Unexpected token (1:8)", {ecmaVersion: 7}); testFail("var a = [if (x) x]", "Unexpected token (1:9)", {ecmaVersion: 6}); -testFail("[for (x of [])] // no expression", "Unexpected token (1:14)", {ecmaVersion: 6}); +testFail("[for (x of [])] // no expression", "Unexpected token (1:14)", {ecmaVersion: 7}); testFail("({ \"chance\" }) = obj", "Unexpected token (1:12)", {ecmaVersion: 6}); @@ -15412,4 +15412,4 @@ test("(for (x of array) for (y of array2) if (x === test) x)", { type: "ComprehensionExpression" } }] -}, {ecmaVersion: 6, preserveParens: true}); +}, {ecmaVersion: 7, preserveParens: true});