Bug 975484 - Reflect.parse location information is inaccurate for CallExpressions. r=luke.
authorJason Orendorff <jorendorff@mozilla.com>
Wed, 26 Feb 2014 08:55:35 -0600
changeset 171034 7a2bb8e2f3cb90771f190016e5f8cd1ca6988266
parent 171033 b130f02b5151dda4b7046c4028ad4f849499f129
child 171035 c90e26bbcdf58173fbef9118a9a7092c4a813d62
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersluke
bugs975484
milestone30.0a1
Bug 975484 - Reflect.parse location information is inaccurate for CallExpressions. r=luke.
js/src/frontend/Parser.cpp
js/src/jit-test/tests/parser/bug-975484.js
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -6424,18 +6424,20 @@ Parser<ParseHandler>::assignExprWithoutY
     }
     return res;
 }
 
 template <typename ParseHandler>
 bool
 Parser<ParseHandler>::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;
 
     do {
         bool spread = false;
         uint32_t begin = 0;
         if (tokenStream.matchToken(TOK_TRIPLEDOT, TokenStream::Operand)) {
@@ -6478,16 +6480,17 @@ Parser<ParseHandler>::argumentList(Node 
 
         handler.addList(listNode, argNode);
     } while (tokenStream.matchToken(TOK_COMMA));
 
     if (tokenStream.getToken() != TOK_RP) {
         report(ParseError, false, null(), JSMSG_PAREN_AFTER_ARGS);
         return false;
     }
+    handler.setEndPosition(listNode, pos().end);
     return true;
 }
 
 template <typename ParseHandler>
 typename ParseHandler::Node
 Parser<ParseHandler>::memberExpr(TokenKind tt, bool allowCallSyntax)
 {
     JS_ASSERT(tokenStream.isCurrentTokenType(tt));
new file mode 100644
--- /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);