diff --git a/src/parser.cc b/src/parser.cc index a93600f960..6b53cb5356 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -3435,6 +3435,7 @@ Expression* Parser::ParseLeftHandSideExpression(bool* ok) { top_scope_->DeclarationScope()->RecordEvalCall(); } result = factory()->NewCall(result, args, pos); + if (fni_ != NULL) fni_->RemoveLastFunction(); break; } diff --git a/test/cctest/test-func-name-inference.cc b/test/cctest/test-func-name-inference.cc index a86dfd28a1..dcc6272a39 100644 --- a/test/cctest/test-func-name-inference.cc +++ b/test/cctest/test-func-name-inference.cc @@ -258,6 +258,57 @@ TEST(MultipleFuncsInLiteral) { } +TEST(AnonymousInAnonymousClosure1) { + CcTest::InitializeVM(); + v8::HandleScope scope(CcTest::isolate()); + + v8::Handle 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 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 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 TEST(Issue380) { CcTest::InitializeVM();