Index: src/parser.cc |
diff --git a/src/parser.cc b/src/parser.cc |
index 62b633ea2807f4edbfed4d6147196058f3745ec9..2b2cf65d1f2fc5b4ec61474fb227fc9ee98e0e5a 100644 |
--- a/src/parser.cc |
+++ b/src/parser.cc |
@@ -656,6 +656,16 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, |
CheckConflictingVarDeclarations(top_scope_, &ok); |
} |
+ if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) { |
+ if (body->length() != 1 || |
+ !body->at(0)->IsExpressionStatement() || |
+ !body->at(0)->AsExpressionStatement()-> |
+ expression()->IsFunctionLiteral()) { |
+ ReportMessage("unable_to_parse", Vector<const char*>::empty()); |
+ ok = false; |
+ } |
+ } |
+ |
if (ok) { |
result = factory()->NewFunctionLiteral( |
no_name, |