Bug 1296814 - Report the error for uninitialized const-declaration in for(;;) loop head using an explicit offset. r=anba
authorJeff Walden <jwalden@mit.edu>
Sun, 13 Nov 2016 00:12:38 -0800
changeset 322563 4ea1d15d3f868dddc620e6eee355e338e46e5948
parent 322562 aaee337ec6467468be549b20e6ee617acb2810f1
child 322564 3bce123564a38dc594fe15d0ad73cee2aa3a5cfb
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
reviewersanba
bugs1296814
milestone52.0a1
Bug 1296814 - Report the error for uninitialized const-declaration in for(;;) loop head using an explicit offset. r=anba
js/src/frontend/Parser.cpp
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -4488,17 +4488,17 @@ Parser<ParseHandler>::declarationName(No
         if (forHeadKind && *forHeadKind != PNK_FORHEAD) {
             *forInOrOfExpression = expressionAfterForInOrOf(*forHeadKind, yieldHandling);
             if (!*forInOrOfExpression)
                 return null();
         } else {
             // Normal const declarations, and const declarations in for(;;)
             // heads, must be initialized.
             if (declKind == DeclarationKind::Const) {
-                reportWithNode(ParseError, false, binding, JSMSG_BAD_CONST_DECL);
+                errorAt(namePos.begin, JSMSG_BAD_CONST_DECL);
                 return null();
             }
         }
     }
 
     // Note the declared name after knowing whether or not we are in a for-of
     // loop, due to special early error semantics in Annex B.3.5.
     if (!noteDeclaredName(name, declKind, namePos))