[Pkg-javascript-commits] [node-acorn-jsx] 107/484: Fix node boundaries for unexpected regular expressions

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:11 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 38179fd85506ebfd22ebaacab02025c1def1c754
Author: Marijn Haverbeke <marijnh at gmail.com>
Date:   Thu Feb 28 19:28:20 2013 +0100

    Fix node boundaries for unexpected regular expressions
    
    Closes #33
---
 acorn.js      |  3 ++-
 test/tests.js | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/acorn.js b/acorn.js
index d61d19c..b2a513d 100644
--- a/acorn.js
+++ b/acorn.js
@@ -679,7 +679,8 @@
   }
 
   function readToken(forceRegexp) {
-    tokStart = tokPos;
+    if (!forceRegexp) tokStart = tokPos;
+    else tokPos = tokStart + 1;
     if (options.locations) tokStartLoc = new line_loc_t;
     if (forceRegexp) return readRegexp();
     if (tokPos >= inputLen) return finishToken(_eof);
diff --git a/test/tests.js b/test/tests.js
index f01f5d3..b4c0005 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -26097,6 +26097,38 @@ test("foo: 10; foo: 20;", {
   ]
 });
 
+test("if(1)/  foo/", {
+  type: "Program",
+  start: 0,
+  end: 12,
+  body: [
+    {
+      type: "IfStatement",
+      start: 0,
+      end: 12,
+      test: {
+        type: "Literal",
+        start: 3,
+        end: 4,
+        value: 1,
+        raw: "1"
+      },
+      consequent: {
+        type: "ExpressionStatement",
+        start: 5,
+        end: 12,
+        expression: {
+          type: "Literal",
+          start: 5,
+          end: 12,
+          raw: "/  foo/"
+        }
+      },
+      alternate: null
+    }
+  ]
+});
+
 // option tests
 
 test("var a = 1;", {

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