[Pkg-javascript-commits] [node-acorn-jsx] 369/484: Fixed #186.

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:57 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 0084ac14ae807f3f796474e2af65c0d1a94f91b7
Author: Ingvar Stepanyan <me at rreverser.com>
Date:   Tue Dec 30 13:42:06 2014 +0200

    Fixed #186.
---
 acorn.js              |  3 ++-
 acorn_loose.js        |  3 ++-
 test/tests-harmony.js | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/acorn.js b/acorn.js
index 3f15583..1208b87 100644
--- a/acorn.js
+++ b/acorn.js
@@ -2223,7 +2223,8 @@
         prop.method = true;
         prop.value = parseMethod(isGenerator);
       } else if (options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
-                 (prop.key.name === "get" || prop.key.name === "set")) {
+                 (prop.key.name === "get" || prop.key.name === "set") &&
+                 (tokType != _comma && tokType != _braceR)) {
         if (isGenerator) unexpected();
         prop.kind = prop.key.name;
         parsePropertyName(prop);
diff --git a/acorn_loose.js b/acorn_loose.js
index 6262162..a0d822a 100644
--- a/acorn_loose.js
+++ b/acorn_loose.js
@@ -882,7 +882,8 @@
         }
         prop.value = parseMethod(isGenerator);
       } else if (options.ecmaVersion >= 5 && prop.key.type === "Identifier" &&
-                 (prop.key.name === "get" || prop.key.name === "set")) {
+                 (prop.key.name === "get" || prop.key.name === "set") &&
+                 (token.type != tt.comma && token.type != tt.braceR)) {
         prop.kind = prop.key.name;
         parsePropertyName(prop);
         prop.value = parseMethod(false);
diff --git a/test/tests-harmony.js b/test/tests-harmony.js
index fbe33be..1dbbeff 100644
--- a/test/tests-harmony.js
+++ b/test/tests-harmony.js
@@ -14405,3 +14405,37 @@ test("`{${x}}`, `}`", {
     }
   }]
 }, {ecmaVersion: 6});
+
+// https://github.com/marijnh/acorn/issues/186
+test('var {get} = obj;', {
+  type: "Program",
+  body: [{
+    type: "VariableDeclaration",
+    declarations: [{
+      type: "VariableDeclarator",
+      id: {
+        type: "ObjectPattern",
+        properties: [{
+          type: "Property",
+          method: false,
+          shorthand: true,
+          computed: false,
+          key: {
+            type: "Identifier",
+            name: "get"
+          },
+          kind: "init",
+          value: {
+            type: "Identifier",
+            name: "get"
+          }
+        }]
+      },
+      init: {
+        type: "Identifier",
+        name: "obj"
+      }
+    }],
+    kind: "var"
+  }]
+}, {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