[Pkg-javascript-commits] [node-acorn-jsx] 338/484: Loose: support for-of without var.

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:52 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 aa96edf76932d7ed86a69246888b86728e042ee5
Author: Ingvar Stepanyan <me at rreverser.com>
Date:   Mon Oct 27 02:43:33 2014 +0200

    Loose: support for-of without var.
---
 acorn_loose.js | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/acorn_loose.js b/acorn_loose.js
index 8a75e3d..197e184 100644
--- a/acorn_loose.js
+++ b/acorn_loose.js
@@ -338,17 +338,15 @@
       if (token.type === tt.semi) return parseFor(node, null);
       if (token.type === tt._var || token.type === tt._let) {
         var init = parseVar(true);
-        if (init.declarations.length === 1) {
-          if (eat(tt._in)) return parseForIn(node, init);
-          if (token.type === tt.name && token.value === "of") {
-            next();
-            return parseForIn(node, init, true);
-          }
+        if (init.declarations.length === 1 && (token.type === tt._in || token.type === tt.name && token.value === "of")) {
+          return parseForIn(node, init);
         }
         return parseFor(node, init);
       }
       var init = parseExpression(false, true);
-      if (eat(tt._in)) return parseForIn(node, checkLVal(init));
+      if (token.type === tt._in || token.type === tt.name && token.value === "of") {
+        return parseForIn(node, checkLVal(init));
+      }
       return parseFor(node, init);
 
     case tt._function:
@@ -493,13 +491,15 @@
     return finishNode(node, "ForStatement");
   }
 
-  function parseForIn(node, init, isOf) {
+  function parseForIn(node, init) {
+    var type = token.type === tt._in ? "ForInStatement" : "ForOfStatement";
+    next();
     node.left = init;
     node.right = parseExpression();
     popCx();
     expect(tt.parenR);
     node.body = parseStatement();
-    return finishNode(node, isOf ? "ForOfStatement" : "ForInStatement");
+    return finishNode(node, type);
   }
 
   function parseVar(noIn) {

-- 
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