[Pkg-javascript-commits] [node-acorn-jsx] 290/484: Only accept for-of loops in ECMA6 mode.

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:44 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-acorn-jsx.

commit 015a0e90bcbd5c4093650917d1373d211c086a41
Author: Max Schaefer <max at semmle.com>
Date:   Mon Sep 29 10:16:22 2014 +0100

    Only accept for-of loops in ECMA6 mode.
---
 acorn.js      | 4 ++--
 test/tests.js | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/acorn.js b/acorn.js
index aafc34d..8d4760d 100644
--- a/acorn.js
+++ b/acorn.js
@@ -1584,13 +1584,13 @@
       next();
       parseVar(init, true, varKind);
       finishNode(init, "VariableDeclaration");
-      if ((tokType === _in || (tokType === _name && tokVal === "of")) && init.declarations.length === 1 &&
+      if ((tokType === _in || (options.ecmaVersion >= 6 && tokType === _name && tokVal === "of")) && init.declarations.length === 1 &&
           !(isLet && init.declarations[0].init))
         return parseForIn(node, init);
       return parseFor(node, init);
     }
     var init = parseExpression(false, true);
-    if (tokType === _in || (tokType === _name && tokVal === "of")) {
+    if (tokType === _in || (options.ecmaVersion >= 6 && tokType === _name && tokVal === "of")) {
       checkLVal(init);
       return parseForIn(node, init);
     }
diff --git a/test/tests.js b/test/tests.js
index 936e73a..40069ee 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -28594,6 +28594,10 @@ testFail("const a;", "Unexpected token (1:7)", {ecmaVersion: 6});
 
 testFail("for(const x = 0;;);", "Unexpected token (1:4)", {ecmaVersion: 6});
 
+testFail("for(x of a);", "Unexpected token (1:6)");
+
+testFail("for(var x of a);", "Unexpected token (1:10)");
+
 // Assertion Tests
 (function() {
   var actualComments = [],

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git



More information about the Pkg-javascript-commits mailing list