diff --git a/acorn.js b/acorn.js index e0e8b63510..4d5b23e578 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 2c52cf1987..968745e008 100644 --- a/index.html +++ b/index.html @@ -776,7 +776,7 @@ to its body instead of creating a new node.

if (foo) /blah/.exec(foo);, where looking at the previous token does not help.

  function parseStatement() {
-    if (tokType === _slash)
+    if (tokType === _slash || tokType === _assign && tokVal == "/=")
       readToken(true);
 
     var starttype = tokType, node = startNode();

Most types of statements are recognized by the keyword they diff --git a/test/tests.js b/test/tests.js index 8c427868b2..f021de1328 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)"); } ); })(); -