Bug 1533399 - Fix field positions. r=jorendorff
authorAshley Hauck <khyperia@mozilla.com>
Fri, 08 Mar 2019 15:40:01 +0000
changeset 521166 fc19e9b1f6bb
parent 521165 6717beb3ac53
child 521167 cd9ef3b60bc3
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1533399
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1533399 - Fix field positions. r=jorendorff Differential Revision: https://phabricator.services.mozilla.com/D22519
js/src/frontend/Parser.cpp
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -7277,42 +7277,47 @@ GeneralParser<ParseHandler, Unit>::field
 
   // Parse the expression for the field initializer.
   Node initializerExpr =
       assignExpr(InAllowed, yieldHandling, TripledotProhibited);
   if (!initializerExpr) {
     return null();
   }
 
+  TokenPos wholeInitializerPos = pos();
+  wholeInitializerPos.begin = firstTokenPos.begin;
+
+  // Update the end position of the parse node.
+  handler_.setEndPosition(funNode, wholeInitializerPos.end);
+  funbox->setEnd(anyChars);
+
   // Create a ListNode for the parameters + body (there are no parameters).
   ListNodeType argsbody =
-      handler_.newList(ParseNodeKind::ParamsBody, firstTokenPos);
+      handler_.newList(ParseNodeKind::ParamsBody, wholeInitializerPos);
   if (!argsbody) {
     return null();
   }
   handler_.setFunctionFormalParametersAndBody(funNode, argsbody);
   funbox->function()->setArgCount(0);
 
-  funbox->setEnd(anyChars);
-
   funbox->usesThis = true;
   NameNodeType thisName = newThisName();
   if (!thisName) {
     return null();
   }
 
   // Build `this.field` expression.
   ThisLiteralType propAssignThis =
-      handler_.newThisLiteral(firstTokenPos, thisName);
+      handler_.newThisLiteral(wholeInitializerPos, thisName);
   if (!propAssignThis) {
     return null();
   }
 
   NameNodeType propAssignName =
-      handler_.newPropertyName(propAtom->asPropertyName(), firstTokenPos);
+      handler_.newPropertyName(propAtom->asPropertyName(), wholeInitializerPos);
   if (!propAssignName) {
     return null();
   }
 
   PropertyAccessType propAssignFieldAccess =
       handler_.newPropertyAccess(propAssignThis, propAssignName);
   if (!propAssignFieldAccess) {
     return null();
@@ -7331,17 +7336,17 @@ GeneralParser<ParseHandler, Unit>::field
   }
 
   UnaryNodeType exprStatement =
       handler_.newExprStatement(initializerAssignment, pos().end);
   if (!exprStatement) {
     return null();
   }
 
-  ListNodeType statementList = handler_.newStatementList(firstTokenPos);
+  ListNodeType statementList = handler_.newStatementList(wholeInitializerPos);
   if (!argsbody) {
     return null();
   }
   handler_.addStatementToList(statementList, exprStatement);
 
   // Set the function's body to the field assignment.
   LexicalScopeNodeType initializerBody =
       finishLexicalScope(lexicalScope, statementList);