[Pkg-javascript-commits] [node-acorn-jsx] 398/484: Add stray semicolons as class elements

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:21:02 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 9f7cb552648829796ab4d6836d08246e95f16b9d
Author: Sebastian McKenzie <sebmck at gmail.com>
Date:   Sun Jan 4 21:08:39 2015 +1100

    Add stray semicolons as class elements
---
 acorn.js              |  3 ++-
 test/tests-harmony.js | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/acorn.js b/acorn.js
index 4945981..6ba8f97 100644
--- a/acorn.js
+++ b/acorn.js
@@ -2524,6 +2524,8 @@
     classBody.body = [];
     expect(_braceL);
     while (!eat(_braceR)) {
+      while (eat(_semi));
+      if (tokType === _braceR) continue;
       var method = startNode();
       var isGenerator = eat(_star);
       parsePropertyName(method);
@@ -2546,7 +2548,6 @@
       }
       method.value = parseMethod(isGenerator);
       classBody.body.push(finishNode(method, "MethodDefinition"));
-      eat(_semi);
     }
     node.body = finishNode(classBody, "ClassBody");
     return finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
diff --git a/test/tests-harmony.js b/test/tests-harmony.js
index eb8b8c5..086d852 100644
--- a/test/tests-harmony.js
+++ b/test/tests-harmony.js
@@ -8859,6 +8859,42 @@ test("class A { foo() {} get foo() {} }",{
   locations: true
 });
 
+test("class Semicolon { ; }", {
+  type: "Program",
+  loc: {
+    start: {line: 1, column: 0},
+    end: {line: 1, column: 21}
+  },
+  body: [{
+    type: "ClassDeclaration",
+    loc: {
+      start: {line: 1, column: 0},
+      end: {line: 1, column: 21}
+    },
+    id: {
+      type: "Identifier",
+      loc: {
+        start: {line: 1, column: 6},
+        end: {line: 1, column: 15}
+      },
+      name: "Semicolon"
+    },
+    superClass: null,
+    body: {
+      type: "ClassBody",
+      loc: {
+        start: {line: 1, column: 16},
+        end: {line: 1, column: 21}
+      },
+      body: []
+    }
+  }]
+}, {
+  ecmaVersion: 6,
+  ranges: true,
+  locations: true
+});
+
 // ES6: Computed Properties
 
 test("({[x]: 10})", {

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