[Pkg-javascript-commits] [node-acorn-jsx] 165/484: Fix bug causing comments after 'use strict' to be handled twice

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:20 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 dd456e3ad52de2ffbeca9866f02d0f0f09c56ab8
Author: Marijn Haverbeke <marijnh at gmail.com>
Date:   Mon Nov 11 11:25:59 2013 +0100

    Fix bug causing comments after 'use strict' to be handled twice
    
    Closes #76
---
 acorn.js      | 2 +-
 index.html    | 2 +-
 test/tests.js | 7 +++++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/acorn.js b/acorn.js
index 0f525ee..e03f6f2 100644
--- a/acorn.js
+++ b/acorn.js
@@ -976,7 +976,7 @@
 
   function setStrict(strct) {
     strict = strct;
-    tokPos = lastEnd;
+    tokPos = tokStart;
     if (options.locations) {
       while (tokPos < tokLineStart) {
         tokLineStart = input.lastIndexOf("\n", tokLineStart - 2) + 1;
diff --git a/index.html b/index.html
index 18d4291..8b53efc 100644
--- a/index.html
+++ b/index.html
@@ -697,7 +697,7 @@ precedence levels that JavaScript defines.</p>             </td>             <td
   <span class="p">}</span></pre></div>             </td>           </tr>                               <tr id="section-82">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-82">¶</a>               </div>               <p>Enter strict mode. Re-reads the next token to please pedantic
 tests ("use strict"; 010; -- should fail).</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">function</span> <span class="nx">setStrict</span><span class="p">(</span><span class="nx">strct</span><span class="p">)</span> <span class="p">{</span>
     <span class="nx">strict</span> <span class="o">=</span> <span class="nx">strct</span><span class="p">;</span>
-    <span class="nx">tokPos</span> <span class="o">=</span> <span class="nx">lastEnd</span><span class="p">;</span>
+    <span class="nx">tokPos</span> <span class="o">=</span> <span class="nx">tokStart</span><span class="p">;</span>
     <span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">locations</span><span class="p">)</span> <span class="p">{</span>
       <span class="k">while</span> <span class="p">(</span><span class="nx">tokPos</span> <span class="o"><</span> <span class="nx">tokLineStart</span><span class="p">)</span> <span class="p">{</span>
         <span class="nx">tokLineStart</span> <span class="o">=</span> <span class="nx">input</span><span class="p">.</span><span class="nx">lastIndexOf</span><span class="p">(</span><span class="s2">"\n"</span><span class="p">,</span> <span class="nx">tokLineStart</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
diff --git a/test/tests.js b/test/tests.js
index c9a080e..efce0b4 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -26956,3 +26956,10 @@ testFail("throw\n10;", "Illegal newline after throw (1:5)");
     }
   );
 })();
+
+(function() {
+  var comments = 0;
+  testAssert("\nfunction plop() {\n'use strict';\n/* Comment */\n}", function() {
+    if (comments != 1) return "Comment after strict counted twice.";
+  }, {onComment: function() {++comments;}});
+})();

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