diff --git a/src/ast-value-factory.h b/src/ast-value-factory.h index 59efa58c51..7749b5cf33 100644 --- a/src/ast-value-factory.h +++ b/src/ast-value-factory.h @@ -248,6 +248,9 @@ class AstValueFactory { const AstString* GetString(Handle literal); void Internalize(Isolate* isolate); + bool IsInternalized() { + return isolate_ != NULL; + } #define F(name, str) \ const AstString* name##_string() const { return name##_string_; } diff --git a/src/parser.cc b/src/parser.cc index aa686a2d18..42d0949386 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -911,6 +911,7 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, } } + ast_value_factory_->Internalize(isolate()); if (ok) { result = factory()->NewFunctionLiteral( ast_value_factory_->empty_string(), @@ -1031,6 +1032,7 @@ FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) { // Make sure the target stack is empty. ASSERT(target_stack_ == NULL); + ast_value_factory_->Internalize(isolate()); if (result == NULL) { if (stack_overflow()) { isolate()->StackOverflow(); @@ -3884,6 +3886,7 @@ void Parser::RegisterTargetUse(Label* target, Target* stop) { void Parser::ThrowPendingError() { + ASSERT(ast_value_factory_->IsInternalized()); if (has_pending_error_) { MessageLocation location(script_, pending_error_location_.beg_pos, @@ -4844,7 +4847,7 @@ bool Parser::Parse() { } } info()->SetFunction(result); - ast_value_factory_->Internalize(isolate()); + ASSERT(ast_value_factory_->IsInternalized()); // info takes ownership of ast_value_factory_. if (info()->ast_value_factory() == NULL) { info()->SetAstValueFactory(ast_value_factory_); diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc index bd6b06d8d2..79b32e8000 100644 --- a/test/cctest/test-parsing.cc +++ b/test/cctest/test-parsing.cc @@ -2552,3 +2552,20 @@ TEST(FuncNameInferrerEscaped) { i::DeleteArray(two_byte_source); i::DeleteArray(two_byte_name); } + + +TEST(RegressionLazyFunctionWithErrorWithArg) { + // The bug occurred when a lazy function had an error which requires a + // parameter (such as "unknown label" here). The error message was processed + // before the AstValueFactory containing the error message string was + // internalized. + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + LocalContext env; + i::FLAG_lazy = true; + i::FLAG_min_preparse_length = 0; + CompileRun("function this_is_lazy() {\n" + " break p;\n" + "}\n" + "this_is_lazy();\n"); +}