Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index 3f635c70df275ea837606aa81354f6daea36a882..048216ca7a323a69185a66f252b837a34fe8a6c0 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -2990,7 +2990,7 @@ Statement* Parser::ParseSwitchStatement(ZoneList<const AstRawString*>* labels, |
| // } |
| Block* switch_block = |
| - factory()->NewBlock(NULL, 2, true, RelocInfo::kNoPosition); |
| + factory()->NewBlock(NULL, 2, false, RelocInfo::kNoPosition); |
|
adamk
2015/08/28 22:03:20
We really ought to change this param to an enum so
|
| int switch_pos = peek_position(); |
| Expect(Token::SWITCH, CHECK_OK); |
| @@ -3007,8 +3007,17 @@ Statement* Parser::ParseSwitchStatement(ZoneList<const AstRawString*>* labels, |
| factory()->NewExpressionStatement(tag_assign, RelocInfo::kNoPosition); |
| switch_block->AddStatement(tag_statement, zone()); |
| + // make statement: undefined; |
| + // This is needed so the tag isn't returned as the value, in case the switch |
| + // statements don't have a value. |
| + switch_block->AddStatement( |
| + factory()->NewExpressionStatement( |
| + factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), |
| + RelocInfo::kNoPosition), |
| + zone()); |
| + |
| Block* cases_block = |
| - factory()->NewBlock(NULL, 1, true, RelocInfo::kNoPosition); |
| + factory()->NewBlock(NULL, 1, false, RelocInfo::kNoPosition); |
| Scope* cases_scope = NewScope(scope_, BLOCK_SCOPE); |
| SwitchStatement* switch_statement = |