Bug 1437004 - ParseNode::dump() now displays names for ObjectPropertyNames;r?arai,jorendorff draft
authorDavid Teller <dteller@mozilla.com>
Thu, 15 Feb 2018 12:01:47 +0100
changeset 777851 057da8c4199f92c52d4e950d9142a18a2a83d54b
parent 777850 6a5a780276eea8db4592e846b1dace4dd9a927e3
child 777852 3be52f7bb42088899f3b7166101feffc8d98a3e6
push id105306
push userdteller@mozilla.com
push dateThu, 05 Apr 2018 12:07:57 +0000
reviewersarai, jorendorff
bugs1437004
milestone61.0a1
Bug 1437004 - ParseNode::dump() now displays names for ObjectPropertyNames;r?arai,jorendorff By opposition to the built-in SpiderMonkey parser, the out of tree parser used as part of the BinAST encoder does not make a difference between ```js { foo: 1 } ``` and ```js { "foo": 1 } ``` SpiderMonkey considers that the former example has a literal property name, while the latter has a computed property name. By opposition, the BinAST encoder considers that both are literal property names. While the runtime behavior is identical, this caused SpiderMonkey to print different ASTs when text-parsing both source files, but the same AST when bin-parsing both source files. This patch addresses the issue by changing the behavior of ParseNode::dump() to display names for ObjectPropertyNames instead of the string `ObjectPropertyName`. MozReview-Commit-ID: IPZBl5eglIJ
js/src/frontend/ParseNode.cpp
--- a/js/src/frontend/ParseNode.cpp
+++ b/js/src/frontend/ParseNode.cpp
@@ -686,16 +686,17 @@ NullaryNode::dump(GenericPrinter& out)
         if (cstr)
             out.printf("%s", cstr);
         else
             out.printf("%g", pn_dval);
         break;
       }
 
       case ParseNodeKind::String:
+      case ParseNodeKind::ObjectPropertyName:
         pn_atom->dumpCharsNoNewline(out);
         break;
 
       default:
         out.printf("(%s)", parseNodeNames[size_t(getKind())]);
     }
 }