Bug 1501537 - Name function in variable declaration initializer in BinAST. r=Yoric
authorTooru Fujisawa <arai_a@mac.com>
Tue, 30 Oct 2018 09:49:40 +0900
changeset 499870 f2a70b31cc32e0e5b3fb358105ad660b4b9f42e6
parent 499869 978ef31db350c9984c3a62474b7b7802bfca82d5
child 499871 916db80793cbefc667b019edefeb83559c535b50
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1501537
milestone65.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 1501537 - Name function in variable declaration initializer in BinAST. r=Yoric
js/src/frontend/BinSource-auto.cpp
js/src/frontend/BinSource.yaml
--- a/js/src/frontend/BinSource-auto.cpp
+++ b/js/src/frontend/BinSource-auto.cpp
@@ -5056,21 +5056,21 @@ BinASTParser<Tok>::parseInterfaceVariabl
 
     BINJS_MOZ_TRY_DECL(binding, parseBinding());
 
     BINJS_MOZ_TRY_DECL(init, parseOptionalExpression());
 
     ParseNode* result;
     if (binding->isKind(ParseNodeKind::Name)) {
         // `var foo [= bar]``
-        MOZ_TRY(checkBinding(binding->template as<NameNode>().atom()->asPropertyName()));
-
-        BINJS_TRY_VAR(result, factory_.newName(binding->template as<NameNode>().atom()->asPropertyName(), tokenizer_->pos(start), cx_));
+        NameNode* bindingNameNode = &binding->template as<NameNode>();
+        MOZ_TRY(checkBinding(bindingNameNode->atom()->asPropertyName()));
+        result = bindingNameNode;
         if (init) {
-            result->as<NameNode>().setInitializer(init);
+            BINJS_TRY(factory_.finishInitializerAssignment(bindingNameNode, init));
         }
     } else {
         // `var pattern = bar`
         if (!init) {
             // Here, `init` is required.
             return raiseMissingField("VariableDeclarator (with non-trivial pattern)", BinField::Init);
         }
 
--- a/js/src/frontend/BinSource.yaml
+++ b/js/src/frontend/BinSource.yaml
@@ -1342,21 +1342,21 @@ VariableDeclaration:
         declarators->setKind(pnk);
         auto result = declarators;
 
 VariableDeclarator:
     build: |
         ParseNode* result;
         if (binding->isKind(ParseNodeKind::Name)) {
             // `var foo [= bar]``
-            MOZ_TRY(checkBinding(binding->template as<NameNode>().atom()->asPropertyName()));
-
-            BINJS_TRY_VAR(result, factory_.newName(binding->template as<NameNode>().atom()->asPropertyName(), tokenizer_->pos(start), cx_));
+            NameNode* bindingNameNode = &binding->template as<NameNode>();
+            MOZ_TRY(checkBinding(bindingNameNode->atom()->asPropertyName()));
+            result = bindingNameNode;
             if (init) {
-                result->as<NameNode>().setInitializer(init);
+                BINJS_TRY(factory_.finishInitializerAssignment(bindingNameNode, init));
             }
         } else {
             // `var pattern = bar`
             if (!init) {
                 // Here, `init` is required.
                 return raiseMissingField("VariableDeclarator (with non-trivial pattern)", BinField::Init);
             }