Bug 1296814 - When |continue x| is found outside of a loop, report an error that points at |continue|, not at |x|. r=arai
authorJeff Walden <jwalden@mit.edu>
Mon, 07 Nov 2016 15:23:16 -0800
changeset 322543 fa42c1f05ae9456d6c1a582632e96d2a335fedf0
parent 322542 da5874a0aa949afc15903df8b9353e5bf0997f10
child 322544 645e9d747ed96fdfe93e1db6acd7f71b9fb11369
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
reviewersarai
bugs1296814
milestone52.0a1
Bug 1296814 - When |continue x| is found outside of a loop, report an error that points at |continue|, not at |x|. r=arai
js/src/frontend/Parser.cpp
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -5812,18 +5812,20 @@ Parser<ParseHandler>::continueStatement(
 
     if (label) {
         ParseContext::Statement* stmt = pc->innermostStatement();
         bool foundLoop = false;
 
         for (;;) {
             stmt = ParseContext::Statement::findNearest(stmt, isLoop);
             if (!stmt) {
-                report(ParseError, false, null(),
-                       foundLoop ? JSMSG_LABEL_NOT_FOUND : JSMSG_BAD_CONTINUE);
+                if (foundLoop)
+                    report(ParseError, false, null(), JSMSG_LABEL_NOT_FOUND);
+                else
+                    reportWithOffset(ParseError, false, begin, JSMSG_BAD_CONTINUE);
                 return null();
             }
 
             foundLoop = true;
 
             // Is it labeled by our label?
             bool foundTarget = false;
             stmt = stmt->enclosing();