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

Unified Diff: runtime/vm/parser.cc

Issue 10434005: Disallow repeated formal parameters (issue 2240). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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/co19/co19-runtime.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 7923)
+++ runtime/vm/parser.cc (working copy)
@@ -1034,6 +1034,16 @@
params->has_field_initializer = true;
}
+ // Check that the formal parameter is not repeated.
+ const intptr_t num_existing_parameters =
+ params->num_fixed_parameters + params->num_optional_parameters;
+ for (intptr_t i = 0; i < num_existing_parameters; i++) {
+ ParamDesc& existing_parameter = (*params->parameters)[i];
+ if (existing_parameter.name->Equals(*parameter.name)) {
+ ErrorMsg(parameter.name_pos, "repeated formal parameter");
hausner 2012/05/23 21:34:39 In other places we use the phrase "duplicate", so
+ }
+ }
+
if (CurrentToken() == Token::kLPAREN) {
// This parameter is probably a closure. If we saw the keyword 'var'
// or 'final', a closure is not legal here and we ignore the
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698