diff --git a/acorn.js b/acorn.js index 07c15ee28b..993d1341a3 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 faa7fd8a67..051c15fcdc 100644 --- a/index.html +++ b/index.html @@ -776,6 +776,8 @@ adding statements to.

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/test/tests.js b/test/tests.js index 2b267615b0..464a7f9e4a 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)");