Revision: 14903
Author:   [email protected]
Date:     Fri May 31 05:52:28 2013
Log:      Fix function name inferring inside closures

BUG=224884
[email protected], [email protected]

Review URL: https://codereview.chromium.org/16125007
http://code.google.com/p/v8/source/detail?r=14903

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

=======================================
--- /branches/bleeding_edge/src/parser.cc       Mon May 27 03:53:37 2013
+++ /branches/bleeding_edge/src/parser.cc       Fri May 31 05:52:28 2013
@@ -3435,6 +3435,7 @@
           top_scope_->DeclarationScope()->RecordEvalCall();
         }
         result = factory()->NewCall(result, args, pos);
+        if (fni_ != NULL) fni_->RemoveLastFunction();
         break;
       }

=======================================
--- /branches/bleeding_edge/test/cctest/test-func-name-inference.cc Tue May 28 04:54:52 2013 +++ /branches/bleeding_edge/test/cctest/test-func-name-inference.cc Fri May 31 05:52:28 2013
@@ -256,6 +256,57 @@
   CheckFunctionName(script, "return 1", "MyClass.method1");
   CheckFunctionName(script, "return 2", "MyClass.method1");
 }
+
+
+TEST(AnonymousInAnonymousClosure1) {
+  CcTest::InitializeVM();
+  v8::HandleScope scope(CcTest::isolate());
+
+  v8::Handle<v8::Script> script = Compile(
+      "(function() {\n"
+      "  (function() {\n"
+      "      var a = 1;\n"
+      "      return;\n"
+      "  })();\n"
+      "  var b = function() {\n"
+      "      var c = 1;\n"
+      "      return;\n"
+      "  };\n"
+      "})();");
+  CheckFunctionName(script, "return", "");
+}
+
+
+TEST(AnonymousInAnonymousClosure2) {
+  CcTest::InitializeVM();
+  v8::HandleScope scope(CcTest::isolate());
+
+  v8::Handle<v8::Script> script = Compile(
+      "(function() {\n"
+      "  (function() {\n"
+      "      var a = 1;\n"
+      "      return;\n"
+      "  })();\n"
+      "  var c = 1;\n"
+      "})();");
+  CheckFunctionName(script, "return", "");
+}
+
+
+TEST(NamedInAnonymousClosure) {
+  CcTest::InitializeVM();
+  v8::HandleScope scope(CcTest::isolate());
+
+  v8::Handle<v8::Script> script = Compile(
+      "var foo = function() {\n"
+      "  (function named() {\n"
+      "      var a = 1;\n"
+      "  })();\n"
+      "  var c = 1;\n"
+      "  return;\n"
+      "};");
+  CheckFunctionName(script, "return", "foo");
+}


 // See http://code.google.com/p/v8/issues/detail?id=380

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to