Bug 433529: Part 7 - Name functions whose field in an object literal is a PNK_STRING node. r=jimb
authorAlex Crichton <acrichton@mozilla.com>
Tue, 21 Aug 2012 15:57:54 -0700
changeset 105152 17607e337dfd2587a835cae76a6e292f1b294667
parent 105151 6735faf4d313655951b1557775e3c3da4439407c
child 105153 bbf6a7e1598d66d88322515784c7f5a9084d4b9b
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersjimb
bugs433529
milestone17.0a1
Bug 433529: Part 7 - Name functions whose field in an object literal is a PNK_STRING node. r=jimb
js/src/frontend/NameFunctions.cpp
js/src/jit-test/tests/basic/functionnames.js
--- a/js/src/frontend/NameFunctions.cpp
+++ b/js/src/frontend/NameFunctions.cpp
@@ -187,20 +187,24 @@ class NameResolver
          * Other than the actual assignment, other relevant nodes to naming are
          * those in object initializers and then particular nodes marking a
          * contribution.
          */
         for (int pos = size - 1; pos >= 0; pos--) {
             ParseNode *node = toName[pos];
 
             if (node->isKind(PNK_COLON)) {
-                if (!node->pn_left->isKind(PNK_NAME))
-                    continue;
-                /* special atoms are skipped, but others are dot-appended */
-                if (!special(node->pn_left->pn_atom)) {
+                if (node->pn_left->isKind(PNK_NAME)) {
+                    /* special atoms are skipped, but others are dot-appended */
+                    if (!special(node->pn_left->pn_atom)) {
+                        if (!buf.append(".") || !buf.append(node->pn_left->pn_atom))
+                            return NULL;
+                    }
+                } else if (node->pn_left->isKind(PNK_STRING)) {
+                    /* If a string is explicitly specified, don't see if its special */
                     if (!buf.append(".") || !buf.append(node->pn_left->pn_atom))
                         return NULL;
                 }
             } else {
                 /*
                  * Don't have consecutive '<' characters, and also don't start
                  * with a '<' character.
                  */
--- a/js/src/jit-test/tests/basic/functionnames.js
+++ b/js/src/jit-test/tests/basic/functionnames.js
@@ -109,8 +109,11 @@ assertName(a.b(true), 'a.b/<')
 assertName(a.b(false), 'a.b/<')
 
 function f(g) {
     assertName(g, 'x<');
     return g();
 }
 var x = f(function () { return function() {}; });
 assertName(x, 'x</<');
+
+var a = {'b': function(){}};
+assertName(a.b, 'a.b');