Reviewers: Mikhail Naganov (Chromium), loislo, pfeldman,
Description: Clear pending functions list in FuncNameInferrer when it closes BUG=2146 Please review this at https://chromiumcodereview.appspot.com/10414075/ SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/func-name-inferrer.h M test/cctest/test-func-name-inference.cc Index: src/func-name-inferrer.h =================================================================== --- src/func-name-inferrer.h (revision 11629) +++ src/func-name-inferrer.h (working copy) @@ -88,6 +88,8 @@ void Leave() { ASSERT(IsOpen()); names_stack_.Rewind(entries_stack_.RemoveLast()); + if (entries_stack_.is_empty()) + funcs_to_infer_.Clear(); } private: Index: test/cctest/test-func-name-inference.cc =================================================================== --- test/cctest/test-func-name-inference.cc (revision 11629) +++ test/cctest/test-func-name-inference.cc (working copy) @@ -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
