Index: src/parser.cc |
diff --git a/src/parser.cc b/src/parser.cc |
index 249c9ced35309b935b441a8d917f149c017f5ef5..2c143ecbf89255ad0e8501eee736768e5f3b5521 100644 |
--- a/src/parser.cc |
+++ b/src/parser.cc |
@@ -1106,7 +1106,13 @@ void* Parser::ParseSourceElements(ZoneList<Statement*>* processor, |
} |
Scanner::Location token_loc = scanner().peek_location(); |
- Statement* stat = ParseStatement(NULL, CHECK_OK); |
+ |
+ Statement* stat; |
+ if (peek() == Token::FUNCTION) { |
Mads Ager (chromium)
2011/02/28 08:30:12
You should add a comment here as well to make it c
Martin Maly
2011/02/28 18:57:33
Done.
|
+ stat = ParseFunctionDeclaration(CHECK_OK); |
+ } else { |
+ stat = ParseStatement(NULL, CHECK_OK); |
+ } |
if (stat == NULL || stat->IsEmpty()) { |
directive_prologue = false; // End of directive prologue. |
@@ -1263,8 +1269,17 @@ Statement* Parser::ParseStatement(ZoneStringList* labels, bool* ok) { |
return result; |
} |
- case Token::FUNCTION: |
+ case Token::FUNCTION: { |
+ // In strict mode, FunctionDeclaration is only allowed in the context |
+ // of SourceElements. |
+ if (temp_scope_->StrictMode()) { |
+ ReportMessageAt(scanner().peek_location(), "strict_function", |
+ Vector<const char*>::empty()); |
+ *ok = false; |
+ return NULL; |
+ } |
return ParseFunctionDeclaration(ok); |
+ } |
case Token::NATIVE: |
return ParseNativeDeclaration(ok); |