[Pkg-javascript-commits] [node-acorn-jsx] 36/484: Disallow newline after throw

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:01 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 6b52dc8a8477bfb25a145eff95ee986074d0cf46
Author: Marijn Haverbeke <marijnh at gmail.com>
Date:   Thu Oct 18 15:50:07 2012 +0200

    Disallow newline after throw
    
    Closes #11
---
 acorn.js      | 2 ++
 index.html    | 2 ++
 test/tests.js | 5 ++---
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/acorn.js b/acorn.js
index 07c15ee..993d134 100644
--- a/acorn.js
+++ b/acorn.js
@@ -1104,6 +1104,8 @@
 
     case _throw:
       next();
+      if (newline.test(input.slice(lastEnd, tokStart)))
+        raise(lastEnd, "Illegal newline after throw");
       node.argument = parseExpression();
       return finishNode(node, "ThrowStatement");
 
diff --git a/index.html b/index.html
index faa7fd8..051c15f 100644
--- a/index.html
+++ b/index.html
@@ -776,6 +776,8 @@ adding statements to.</p>             </td>             <td class="code">
 
     <span class="k">case</span> <span class="nx">_throw</span><span class="o">:</span>
       <span class="nx">next</span><span class="p">();</span>
+      <span class="k">if</span> <span class="p">(</span><span class="nx">newline</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">input</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="nx">lastEnd</span><span class="p">,</span> <span class="nx">tokStart</span><span class="p">)))</span>
+        <span class="nx">raise</span><span class="p">(</span><span class="nx">lastEnd</span><span class="p">,</span> <span class="s2">"Illegal newline after throw"</span><span class="p">);</span>
       <span class="nx">node</span><span class="p">.</span><span class="nx">argument</span> <span class="o">=</span> <span class="nx">parseExpression</span><span class="p">();</span>
       <span class="k">return</span> <span class="nx">finishNode</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="s2">"ThrowStatement"</span><span class="p">);</span>
 
diff --git a/test/tests.js b/test/tests.js
index 2b26761..464a7f9 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -26269,9 +26269,6 @@ testFail("throw",
 testFail("throw;",
          "Unexpected token (1:5)");
 
-testFail("throw\n",
-         "Unexpected token (2:0)");
-
 testFail("for (var i, i2 in {});",
          "Unexpected token (1:15)");
 
@@ -26603,3 +26600,5 @@ testFail("(function a(package) { \"use strict\"; })",
          "Defining 'package' in strict mode (1:12)");
 
 testFail("var this = 10;", "Unexpected token (1:4)");
+
+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