Revision: 11653
Author:   [email protected]
Date:     Thu May 24 05:41:55 2012
Log:      Clear pending functions list in FuncNameInferrer when it closes

BUG=v8:2146
Review URL: https://chromiumcodereview.appspot.com/10414075
http://code.google.com/p/v8/source/detail?r=11653

Modified:
 /branches/bleeding_edge/src/func-name-inferrer.h
 /branches/bleeding_edge/test/cctest/test-func-name-inference.cc

=======================================
--- /branches/bleeding_edge/src/func-name-inferrer.h Mon Oct 3 12:18:05 2011 +++ /branches/bleeding_edge/src/func-name-inferrer.h Thu May 24 05:41:55 2012
@@ -88,6 +88,8 @@
   void Leave() {
     ASSERT(IsOpen());
     names_stack_.Rewind(entries_stack_.RemoveLast());
+    if (entries_stack_.is_empty())
+      funcs_to_infer_.Clear();
   }

  private:
=======================================
--- /branches/bleeding_edge/test/cctest/test-func-name-inference.cc Mon Oct 3 12:18:05 2011 +++ /branches/bleeding_edge/test/cctest/test-func-name-inference.cc Thu May 24 05:41:55 2012
@@ -400,3 +400,41 @@
   // See MultipleAssignments test.
   CheckFunctionName(script, "return 2", "Enclosing.Bar");
 }
+
+
+TEST(MethodAssignmentInAnonymousFunctionCall) {
+  InitializeVM();
+  v8::HandleScope scope;
+
+  v8::Handle<v8::Script> script = Compile(
+      "(function () {\n"
+      "    var EventSource = function () { };\n"
+      "    EventSource.prototype.addListener = function () {\n"
+      "        return 2012;\n"
+      "    };\n"
+      "    this.PublicEventSource = EventSource;\n"
+      "})();");
+  CheckFunctionName(script, "return 2012", "EventSource.addListener");
+}
+
+
+TEST(ReturnAnonymousFunction) {
+  InitializeVM();
+  v8::HandleScope scope;
+
+  v8::Handle<v8::Script> script = Compile(
+      "(function() {\n"
+      "  function wrapCode() {\n"
+      "    return function () {\n"
+      "      return 2012;\n"
+      "    };\n"
+      "  };\n"
+      "  var foo = 10;\n"
+      "  function f() {\n"
+      "    return wrapCode();\n"
+      "  }\n"
+      "  this.ref = f;\n"
+      "})()");
+  script->Run();
+  CheckFunctionName(script, "return 2012", "");
+}

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to