diff options
-rw-r--r-- | js/src/frontend/Parser.cpp | 4 | ||||
-rw-r--r-- | js/src/jit-test/tests/parser/missing-closing-brace.js | 13 | ||||
-rw-r--r-- | js/src/js.msg | 1 |
3 files changed, 14 insertions, 4 deletions
diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index 7dc3cdf8ff..3154e41d5b 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -9289,7 +9289,9 @@ Parser<ParseHandler>::arrayInitializer(YieldHandling yieldHandling, PossibleErro } } - MUST_MATCH_TOKEN_MOD(TOK_RB, modifier, JSMSG_BRACKET_AFTER_LIST); + MUST_MATCH_TOKEN_MOD_WITH_REPORT(TOK_RB, modifier, + reportMissingClosing(JSMSG_BRACKET_AFTER_LIST, + JSMSG_BRACKET_OPENED, begin)); } handler.setEndPosition(literal, pos().end); return literal; diff --git a/js/src/jit-test/tests/parser/missing-closing-brace.js b/js/src/jit-test/tests/parser/missing-closing-brace.js index f97cefd81e..6820954aeb 100644 --- a/js/src/jit-test/tests/parser/missing-closing-brace.js +++ b/js/src/jit-test/tests/parser/missing-closing-brace.js @@ -1,13 +1,13 @@ -function test(source, [lineNumber, columnNumber]) { +function test(source, [lineNumber, columnNumber], openType = "{", closeType = "}") { let caught = false; try { Reflect.parse(source, { source: "foo.js" }); } catch (e) { - assertEq(e.message.includes("missing } "), true); + assertEq(e.message.includes("missing " + closeType + " "), true); let notes = getErrorNotes(e); assertEq(notes.length, 1); let note = notes[0]; - assertEq(note.message, "{ opened at line " + lineNumber + ", column " + columnNumber); + assertEq(note.message, openType + " opened at line " + lineNumber + ", column " + columnNumber); assertEq(note.fileName, "foo.js"); assertEq(note.lineNumber, lineNumber); assertEq(note.columnNumber, columnNumber); @@ -81,3 +81,10 @@ var x = { foo: { }; `, [2, 8]); + +// Array literal. +test(` +var x = [ + [ +]; +`, [2, 8], "[", "]"); diff --git a/js/src/js.msg b/js/src/js.msg index a51d999338..ec49d06c93 100644 --- a/js/src/js.msg +++ b/js/src/js.msg @@ -218,6 +218,7 @@ MSG_DEF(JSMSG_BAD_SUPERCALL, 0, JSEXN_SYNTAXERR, "super() is only vali MSG_DEF(JSMSG_BRACKET_AFTER_ARRAY_COMPREHENSION, 0, JSEXN_SYNTAXERR, "missing ] after array comprehension") MSG_DEF(JSMSG_BRACKET_AFTER_LIST, 0, JSEXN_SYNTAXERR, "missing ] after element list") MSG_DEF(JSMSG_BRACKET_IN_INDEX, 0, JSEXN_SYNTAXERR, "missing ] in index expression") +MSG_DEF(JSMSG_BRACKET_OPENED, 2, JSEXN_NOTE, "[ opened at line {0}, column {1}") MSG_DEF(JSMSG_CATCH_AFTER_GENERAL, 0, JSEXN_SYNTAXERR, "catch after unconditional catch") MSG_DEF(JSMSG_CATCH_IDENTIFIER, 0, JSEXN_SYNTAXERR, "missing identifier in catch") MSG_DEF(JSMSG_CATCH_OR_FINALLY, 0, JSEXN_SYNTAXERR, "missing catch or finally after try") |