Index: runtime/vm/parser.cc |
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc |
index 868c27bf54dea1be6e5fe128767128e497a9a605..981c0f077b6040725ecc94e3f6861626efe5f41f 100644 |
--- a/runtime/vm/parser.cc |
+++ b/runtime/vm/parser.cc |
@@ -3504,12 +3504,10 @@ SequenceNode* Parser::ParseFunc(const Function& func, bool check_semicolon) { |
ASSERT(AbstractType::Handle(Z, func.result_type()).IsResolved()); |
ASSERT(func.NumParameters() == params.parameters->length()); |
if (!Function::Handle(func.parent_function()).IsGetterFunction()) { |
- // Parse and discard any formal parameters. They are accessed as |
- // context variables. |
- ParamList discarded_params; |
- ParseFormalParameterList(allow_explicit_default_values, |
- false, |
- &discarded_params); |
+ // Skip formal parameters. They are accessed as context variables. |
+ // Parsing them again (and discarding them) does not work in case of |
+ // default values with same name as already parsed formal parameter. |
+ SkipToMatchingParenthesis(); |
} |
} else if (func.IsSyncGenClosure()) { |
AddSyncGenClosureParameters(¶ms); |
@@ -3517,12 +3515,10 @@ SequenceNode* Parser::ParseFunc(const Function& func, bool check_semicolon) { |
AddFormalParamsToScope(¶ms, current_block_->scope); |
ASSERT(AbstractType::Handle(Z, func.result_type()).IsResolved()); |
if (!Function::Handle(func.parent_function()).IsGetterFunction()) { |
- // Parse and discard any formal parameters. They are accessed as |
- // context variables. |
- ParamList discarded_params; |
- ParseFormalParameterList(allow_explicit_default_values, |
- false, |
- &discarded_params); |
+ // Skip formal parameters. They are accessed as context variables. |
+ // Parsing them again (and discarding them) does not work in case of |
+ // default values with same name as already parsed formal parameter. |
+ SkipToMatchingParenthesis(); |
} |
} else if (func.IsAsyncGenClosure()) { |
AddAsyncGenClosureParameters(¶ms); |
@@ -3531,12 +3527,10 @@ SequenceNode* Parser::ParseFunc(const Function& func, bool check_semicolon) { |
ASSERT(AbstractType::Handle(Z, func.result_type()).IsResolved()); |
ASSERT(func.NumParameters() == params.parameters->length()); |
if (!Function::Handle(func.parent_function()).IsGetterFunction()) { |
- // Parse and discard any formal parameters. They are accessed as |
- // context variables. |
- ParamList discarded_params; |
- ParseFormalParameterList(allow_explicit_default_values, |
- false, |
- &discarded_params); |
+ // Skip formal parameters. They are accessed as context variables. |
+ // Parsing them again (and discarding them) does not work in case of |
+ // default values with same name as already parsed formal parameter. |
+ SkipToMatchingParenthesis(); |
} |
} else { |
ParseFormalParameterList(allow_explicit_default_values, false, ¶ms); |
@@ -14702,10 +14696,7 @@ void Parser::SkipFunctionLiteral() { |
ExpectIdentifier("function name expected"); |
} |
if (CurrentToken() == Token::kLPAREN) { |
- const bool allow_explicit_default_values = true; |
- ParamList params; |
- params.skipped = true; |
- ParseFormalParameterList(allow_explicit_default_values, false, ¶ms); |
+ SkipToMatchingParenthesis(); |
} |
RawFunction::AsyncModifier async_modifier = ParseFunctionModifier(); |
BoolScope allow_await(&this->await_is_keyword_, |