diff --git a/acorn.js b/acorn.js index 552eee7208..07c15ee28b 100644 --- a/acorn.js +++ b/acorn.js @@ -1017,6 +1017,7 @@ labels.pop(); expect(_while); node.test = parseParenExpression(); + semicolon(); return finishNode(node, "DoWhileStatement"); // Disambiguating between a `for` and a `for`/`in` loop is diff --git a/index.html b/index.html index bba0ab301b..faa7fd8a67 100644 --- a/index.html +++ b/index.html @@ -699,6 +699,7 @@ continue to.

< labels.pop(); expect(_while); node.test = parseParenExpression(); + semicolon(); return finishNode(node, "DoWhileStatement");

Disambiguating between a for and a for/in loop is non-trivial. Basically, we have to parse the init var statement or expression, disallowing the in operator (see diff --git a/test/tests.js b/test/tests.js index d9c4670ca1..2b267615b0 100644 --- a/test/tests.js +++ b/test/tests.js @@ -17695,19 +17695,6 @@ test("do keep(); while (true);", { line: 1, column: 0 }, - end: { - line: 1, - column: 23 - } - } - }, - { - type: "EmptyStatement", - loc: { - start: { - line: 1, - column: 23 - }, end: { line: 1, column: 24 @@ -17897,7 +17884,7 @@ test("do { x++; y--; } while (x < 10)", { } }); -test("{ do { } while (false) false }", { +test("{ do { } while (false);false }", { type: "Program", body: [ { @@ -17940,7 +17927,7 @@ test("{ do { } while (false) false }", { }, end: { line: 1, - column: 22 + column: 23 } } },