Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: runtime/vm/parser.cc

Issue 2452623002: Avoid parsing formal type parameters a second time from inside an async body, (Closed)
Patch Set: remove leftover debugging code Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/language/regress_27659_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(&params);
@@ -3517,12 +3515,10 @@ SequenceNode* Parser::ParseFunc(const Function& func, bool check_semicolon) {
AddFormalParamsToScope(&params, 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(&params);
@@ -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, &params);
@@ -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, &params);
+ SkipToMatchingParenthesis();
}
RawFunction::AsyncModifier async_modifier = ParseFunctionModifier();
BoolScope allow_await(&this->await_is_keyword_,
« no previous file with comments | « no previous file | tests/language/regress_27659_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698