Bug 1204368 - Fix modifier used for ASI after do-while. r=Waldo
authorTooru Fujisawa <arai_a@mac.com>
Sat, 12 Sep 2015 09:26:01 +0900
changeset 295549 52681f21ea1289ded93d337acfbfc14bcc6ecf64
parent 295548 48876dcd455e46e048d517c987abb5e084f43f6a
child 295550 3a6d0761268866d9c50fa18f698c96b63e3c4590
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1204368
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1204368 - Fix modifier used for ASI after do-while. r=Waldo
js/src/frontend/Parser.cpp
js/src/jit-test/tests/parser/regexp-after-do-while.js
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -5087,21 +5087,20 @@ Parser<ParseHandler>::doWhileStatement(Y
     if (!cond)
         return null();
 
     // The semicolon after do-while is even more optional than most
     // semicolons in JS.  Web compat required this by 2004:
     //   http://bugzilla.mozilla.org/show_bug.cgi?id=238945
     // ES3 and ES5 disagreed, but ES6 conforms to Web reality:
     //   https://bugs.ecmascript.org/show_bug.cgi?id=157
-    bool matched;
-    if (!tokenStream.matchToken(&matched, TOK_SEMI))
-        return null();
-    if (!matched)
-        tokenStream.addModifierException(TokenStream::OperandIsNone);
+    // To parse |do {} while (true) false| correctly, use Operand.
+    bool ignored;
+    if (!tokenStream.matchToken(&ignored, TOK_SEMI, TokenStream::Operand))
+        return null();
     return handler.newDoWhileStatement(body, cond, TokenPos(begin, pos().end));
 }
 
 template <typename ParseHandler>
 typename ParseHandler::Node
 Parser<ParseHandler>::whileStatement(YieldHandling yieldHandling)
 {
     uint32_t begin = pos().begin;
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/parser/regexp-after-do-while.js
@@ -0,0 +1,8 @@
+// RegExp after do-while get parsed.
+
+load(libdir + "asserts.js");
+
+assertNoWarning(() => Function("do {} while (true) \n /bar/g"), SyntaxError,
+                "RegExp in next line should be parsed");
+assertNoWarning(() => Function("do {} while (true) /bar/g"), SyntaxError,
+                "RegExp in same line should be parsed");