Index: src/parser.h |
diff --git a/src/parser.h b/src/parser.h |
index 4a77d91b0ac859aeb6b938c40c36e4b00d5d37f1..9669ac4434abe6b91d68f28f31a823518fa1b64e 100644 |
--- a/src/parser.h |
+++ b/src/parser.h |
@@ -975,6 +975,7 @@ class Parser : public ParserBase<ParserTraits> { |
Scope* scope; |
VariableMode mode; |
bool is_const; |
+ bool is_rest; |
bool needs_init; |
int declaration_pos; |
int initialization_pos; |
@@ -993,6 +994,8 @@ class Parser : public ParserBase<ParserTraits> { |
Expression* pattern; |
int initializer_position; |
Expression* initializer; |
+ bool is_rest = false; |
+ int rest_literal_index = 0; |
}; |
DeclarationParsingResult() |
@@ -1314,9 +1317,9 @@ Expression* ParserTraits::SpreadCallNew( |
void ParserTraits::AddFormalParameter( |
ParserFormalParameters* parameters, Expression* pattern, bool is_rest) { |
- bool is_simple = pattern->IsVariableProxy(); |
- DCHECK(parser_->allow_harmony_destructuring() || |
- parser_->allow_harmony_rest_parameters() || is_simple); |
+ bool is_simple = !is_rest && pattern->IsVariableProxy(); |
+ DCHECK((!is_rest || parser_->allow_harmony_rest_parameters()) || |
+ (!is_simple && parser_->allow_harmony_destructuring()) || is_simple); |
const AstRawString* name = is_simple |
? pattern->AsVariableProxy()->raw_name() |
: parser_->ast_value_factory()->empty_string(); |
@@ -1330,10 +1333,9 @@ void ParserTraits::DeclareFormalParameter( |
Scope* scope, const ParserFormalParameters::Parameter& parameter, |
bool is_simple, ExpressionClassifier* classifier) { |
bool is_duplicate = false; |
- // TODO(caitp): Remove special handling for rest once desugaring is in. |
- auto name = is_simple || parameter.is_rest |
- ? parameter.name : parser_->ast_value_factory()->empty_string(); |
- auto mode = is_simple || parameter.is_rest ? VAR : TEMPORARY; |
+ auto name = |
+ is_simple ? parameter.name : parser_->ast_value_factory()->empty_string(); |
+ auto mode = is_simple ? VAR : TEMPORARY; |
Variable* var = |
scope->DeclareParameter(name, mode, parameter.is_rest, &is_duplicate); |
if (is_duplicate) { |