[Pkg-javascript-commits] [node-acorn-jsx] 140/484: Fix special case to handle regexps that start with =

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:16 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 6659f7a0334ef83c47ffc982a8a4b51a1e944d3c
Author: Marijn Haverbeke <marijnh at gmail.com>
Date:   Wed Aug 28 10:35:21 2013 +0200

    Fix special case to handle regexps that start with =
    
    Closes #55
---
 acorn.js      |  2 +-
 index.html    |  2 +-
 test/tests.js | 18 +++++++++++++++++-
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/acorn.js b/acorn.js
index e0e8b63..4d5b23e 100644
--- a/acorn.js
+++ b/acorn.js
@@ -1099,7 +1099,7 @@
   // does not help.
 
   function parseStatement() {
-    if (tokType === _slash)
+    if (tokType === _slash || tokType === _assign && tokVal == "/=")
       readToken(true);
 
     var starttype = tokType, node = startNode();
diff --git a/index.html b/index.html
index 2c52cf1..968745e 100644
--- a/index.html
+++ b/index.html
@@ -776,7 +776,7 @@ to its body instead of creating a new node.</p>             </td>             <t
 regular expression literal. This is to handle cases like
 <code>if (foo) /blah/.exec(foo);</code>, where looking at the previous token
 does not help.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">function</span> <span class="nx">parseStatement</span><span class="p">()</span> <span class="p">{</span>
-    <span class="k">if</span> <span class="p">(</span><span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_slash</span><span class="p">)</span>
+    <span class="k">if</span> <span class="p">(</span><span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_slash</span> <span class="o">||</span> <span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_assign</span> <span class="o">&&</span> <span class="nx">tokVal</span> <span class="o">==</span> <span class="s2">"/="</span><span class="p">)</span>
       <span class="nx">readToken</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
 
     <span class="kd">var</span> <span class="nx">starttype</span> <span class="o">=</span> <span class="nx">tokType</span><span class="p">,</span> <span class="nx">node</span> <span class="o">=</span> <span class="nx">startNode</span><span class="p">();</span></pre></div>             </td>           </tr>                               <tr id="section-93">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-93">¶</a>     [...]
diff --git a/test/tests.js b/test/tests.js
index 8c42786..f021de1 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -26266,6 +26266,23 @@ test("a.in / b", {
   ]
 });
 
+test("{}/=/", {
+  type: "Program",
+  body: [
+    {
+      type: "BlockStatement",
+      body: []
+    },
+    {
+      type: "ExpressionStatement",
+      expression: {
+        type: "Literal",
+        raw: "/=/"
+      }
+    }
+  ]
+});
+
 // Failure tests
 
 testFail("{",
@@ -26874,4 +26891,3 @@ testFail("throw\n10;", "Illegal newline after throw (1:5)");
     }
   );
 })();
-  

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