Reviewers: alph, loislo, Yang,
Description:
Fix function name inferring inside closures
BUG=224884
Please review this at https://codereview.chromium.org/16125007/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/parser.cc
M test/cctest/test-func-name-inference.cc
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index
a93600f960655756d89b55471004b8f45583088e..6b53cb53562994247e894c5cab0a62f6fabc2f09
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;
}
Index: test/cctest/test-func-name-inference.cc
diff --git a/test/cctest/test-func-name-inference.cc
b/test/cctest/test-func-name-inference.cc
index
a86dfd28a1aab6ae39c307cab87df1d403f04fa5..dcc6272a39ce834787c58d532daf80e39d578370
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<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
TEST(Issue380) {
CcTest::InitializeVM();
--
--
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.