Chromium Code Reviews| Index: src/parsing/parser.cc |
| diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc |
| index c2d32c0d94ee0ffd6f406b67259fab83c054d87d..21b42af0cb01a7db739752d234c0af2e16065320 100644 |
| --- a/src/parsing/parser.cc |
| +++ b/src/parsing/parser.cc |
| @@ -2387,6 +2387,20 @@ static bool ContainsLabel(ZoneList<const AstRawString*>* labels, |
| return false; |
| } |
| +Statement* Parser::ParseOnlyFunctionDeclaration(bool* ok) { |
| + Consume(Token::FUNCTION); |
| + int pos = position(); |
| + bool is_generator = Check(Token::MUL); |
| + if (allow_harmony_restrictive_declarations() && is_generator) { |
| + ParserTraits::ReportMessageAt( |
| + scanner()->location(), |
| + MessageTemplate::kGeneratorInLegacyContext); |
| + *ok = false; |
| + return nullptr; |
| + } |
| + return ParseFunctionDeclaration(pos, is_generator, NULL, CHECK_OK); |
|
adamk
2016/04/20 19:09:28
Nit: nullptr
Dan Ehrenberg
2016/04/26 22:24:18
Fixed
|
| +} |
| + |
| Statement* Parser::ParseExpressionOrLabelledStatement( |
| ZoneList<const AstRawString*>* labels, |
| AllowLabelledFunctionStatement allow_function, bool* ok) { |
| @@ -2443,7 +2457,7 @@ Statement* Parser::ParseExpressionOrLabelledStatement( |
| // ES#sec-labelled-function-declarations Labelled Function Declarations |
| if (peek() == Token::FUNCTION && is_sloppy(language_mode())) { |
| if (allow_function == kAllowLabelledFunctionStatement) { |
| - return ParseFunctionDeclaration(labels, ok); |
|
adamk
2016/04/20 19:09:28
Was this passing of labels just wrong?
Dan Ehrenberg
2016/04/26 22:24:18
Actually, yes. We were confusing labels for export
|
| + return ParseOnlyFunctionDeclaration(ok); |
| } else { |
| return ParseScopedStatement(labels, true, ok); |
| } |
| @@ -3437,7 +3451,7 @@ Statement* Parser::ParseScopedStatement(ZoneList<const AstRawString*>* labels, |
| Scope* body_scope = NewScope(scope_, BLOCK_SCOPE); |
| BlockState block_state(&scope_, body_scope); |
| Block* block = factory()->NewBlock(NULL, 1, false, RelocInfo::kNoPosition); |
| - Statement* body = ParseFunctionDeclaration(NULL, CHECK_OK); |
| + Statement* body = ParseOnlyFunctionDeclaration(CHECK_OK); |
| block->statements()->Add(body, zone()); |
| body_scope->set_end_position(scanner()->location().end_pos); |
| body_scope = body_scope->FinalizeBlockScope(); |