diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index 009e6b109385..f366f9e29ca3 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -6429,8 +6429,10 @@ template bool Parser::argumentList(Node listNode, bool *isSpread) { - if (tokenStream.matchToken(TOK_RP, TokenStream::Operand)) + if (tokenStream.matchToken(TOK_RP, TokenStream::Operand)) { + handler.setEndPosition(listNode, pos().end); return true; + } uint32_t startYieldOffset = pc->lastYieldOffset; bool arg0 = true; @@ -6483,6 +6485,7 @@ Parser::argumentList(Node listNode, bool *isSpread) report(ParseError, false, null(), JSMSG_PAREN_AFTER_ARGS); return false; } + handler.setEndPosition(listNode, pos().end); return true; } diff --git a/js/src/jit-test/tests/parser/bug-975484.js b/js/src/jit-test/tests/parser/bug-975484.js new file mode 100644 index 000000000000..b164492240ff --- /dev/null +++ b/js/src/jit-test/tests/parser/bug-975484.js @@ -0,0 +1,7 @@ +var loc = Reflect.parse("f()").body[0].expression.loc; +assertEq(loc.start.column, 0); +assertEq(loc.end.column, 3); + +loc = Reflect.parse("f(x)").body[0].expression.loc; +assertEq(loc.start.column, 0); +assertEq(loc.end.column, 4);