Bug 1437004 - ParseNode::dump() now displays names for ObjectPropertyNames;r?arai,jorendorff
authorDavid Teller <dteller@mozilla.com>
Thu, 15 Feb 2018 12:01:47 +0100
changeset 770035 235a5b9b02efefb00a294e286655baee4220ff62
parent 770034 1ba2940a7fe4b5b373297ec1a8853ecfa78bedb2
child 770036 bb37239238c37896d7c33bf5a9538e0f61ff4e78
push id103291
push userdteller@mozilla.com
push dateTue, 20 Mar 2018 15:29:40 +0000
reviewersarai, jorendorff
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
--- 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);
             out.printf("%g", pn_dval);
       case ParseNodeKind::String:
+      case ParseNodeKind::ObjectPropertyName:
         out.printf("(%s)", parseNodeNames[size_t(getKind())]);