[INFER] Don't resolve NAME accesses which are on the DeclEnv of named lambdas, bug 685313.
authorBrian Hackett <bhackett1024@gmail.com>
Thu, 08 Sep 2011 17:44:17 -0700
changeset 77058 353b160fb80453368fbe3e9b43810b11ded199fe
parent 77057 c1f0817e5cb4877273b90f6c5d07be9043d09413
child 77059 9459096a263afea32cc8384f50d4d5fea17d31df
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
bugs685313
milestone9.0a1
[INFER] Don't resolve NAME accesses which are on the DeclEnv of named lambdas, bug 685313.
js/src/jit-test/tests/basic/bug685313.js
js/src/jsinfer.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug685313.js
@@ -0,0 +1,11 @@
+
+function foo() {
+    function D(){}
+    arr = [
+	   new (function D   (  ) { 
+		   D += '' + foo; 
+	       }), 
+        new D
+	   ];
+}
+foo();
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -3216,16 +3216,24 @@ ScriptAnalysis::resolveNameAccess(JSCont
             access.slot = (kind == ARGUMENT) ? ArgSlot(index) : LocalSlot(script, index);
             access.arg = (kind == ARGUMENT);
             access.index = index;
             return access;
         } else if (kind != NONE) {
             return access;
         }
 
+        /*
+         * The script's bindings do not contain a name for the function itself,
+         * don't resolve name accesses on lambdas in DeclEnv objects on the
+         * scope chain.
+         */
+        if (atom == CallObjectLambdaName(script->function()))
+            return access;
+
         if (!script->nesting()->parent)
             return access;
         script = script->nesting()->parent;
     }
 
     return access;
 }