[Pkg-javascript-commits] [node-acorn-jsx] 349/484: Fixed import declaration for default+batch case.

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:54 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 4496ca411ade6f71fc5dbf4b322bfe929a82e14b
Author: Ingvar Stepanyan <me at rreverser.com>
Date:   Sat Nov 15 10:26:05 2014 +0200

    Fixed import declaration for default+batch case.
    
    Also removed deprecated `kind` property.
    Fixes #161.
---
 acorn.js              | 23 ++++++++++-------------
 test/tests-harmony.js | 31 +++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/acorn.js b/acorn.js
index 526c3a4..753ba2b 100644
--- a/acorn.js
+++ b/acorn.js
@@ -2551,9 +2551,6 @@
       if (tokType !== _name || tokVal !== "from") unexpected();
       next();
       node.source = tokType === _string ? parseExprAtom() : unexpected();
-      // only for backward compatibility with Esprima's AST
-      // (it doesn't support mixed default + named yet)
-      node.kind = node.specifiers[0]['default'] ? "default" : "named";
     }
     semicolon();
     return finishNode(node, "ImportDeclaration");
@@ -2563,16 +2560,6 @@
 
   function parseImportSpecifiers() {
     var nodes = [], first = true;
-    if (tokType === _star) {
-      var node = startNode();
-      next();
-      if (tokType !== _name || tokVal !== "as") unexpected();
-      next();
-      node.name = parseIdent();
-      checkLVal(node.name, true);
-      nodes.push(finishNode(node, "ImportBatchSpecifier"));
-      return nodes;
-    }
     if (tokType === _name) {
       // import defaultObj, { x, y as z } from '...'
       var node = startNode();
@@ -2583,6 +2570,16 @@
       nodes.push(finishNode(node, "ImportSpecifier"));
       if (!eat(_comma)) return nodes;
     }
+    if (tokType === _star) {
+      var node = startNode();
+      next();
+      if (tokType !== _name || tokVal !== "as") unexpected();
+      next();
+      node.name = parseIdent();
+      checkLVal(node.name, true);
+      nodes.push(finishNode(node, "ImportBatchSpecifier"));
+      return nodes;
+    }
     expect(_braceL);
     while (!eat(_braceR)) {
       if (!first) {
diff --git a/test/tests-harmony.js b/test/tests-harmony.js
index f5064c8..15e3b98 100644
--- a/test/tests-harmony.js
+++ b/test/tests-harmony.js
@@ -14160,3 +14160,34 @@ test("(for (x of array) for (y of array2) if (x === test) x)", {
     }
   }]
 }, {ecmaVersion: 7, preserveParens: true});
+
+// https://github.com/marijnh/acorn/issues/161
+test("import foo, * as bar from 'baz';", {
+  type: "Program",
+  body: [{
+    type: "ImportDeclaration",
+    specifiers: [
+      {
+        type: "ImportSpecifier",
+        id: {
+          type: "Identifier",
+          name: "foo"
+        },
+        name: null,
+        default: true
+      },
+      {
+        type: "ImportBatchSpecifier",
+        name: {
+          type: "Identifier",
+          name: "bar"
+        }
+      }
+    ],
+    source: {
+      type: "Literal",
+      value: "baz",
+      raw: "'baz'"
+    }
+  }]
+}, {ecmaVersion: 6});

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