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

Side by Side Diff: runtime/vm/parser.cc

Issue 23478005: Add compilation error on named parameters with private names (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 parameter.is_field_initializer = true; 1403 parameter.is_field_initializer = true;
1404 } 1404 }
1405 1405
1406 // At this point, we must see an identifier for the parameter name. 1406 // At this point, we must see an identifier for the parameter name.
1407 parameter.name_pos = TokenPos(); 1407 parameter.name_pos = TokenPos();
1408 parameter.name = ExpectIdentifier("parameter name expected"); 1408 parameter.name = ExpectIdentifier("parameter name expected");
1409 if (parameter.is_field_initializer) { 1409 if (parameter.is_field_initializer) {
1410 params->has_field_initializer = true; 1410 params->has_field_initializer = true;
1411 } 1411 }
1412 1412
1413 if (params->has_optional_named_parameters &&
1414 (parameter.name->CharAt(0) == '_')) {
1415 ErrorMsg(parameter.name_pos, "named parameter must not be private");
1416 }
1417
1413 // Check for duplicate formal parameters. 1418 // Check for duplicate formal parameters.
1414 const intptr_t num_existing_parameters = 1419 const intptr_t num_existing_parameters =
1415 params->num_fixed_parameters + params->num_optional_parameters; 1420 params->num_fixed_parameters + params->num_optional_parameters;
1416 for (intptr_t i = 0; i < num_existing_parameters; i++) { 1421 for (intptr_t i = 0; i < num_existing_parameters; i++) {
1417 ParamDesc& existing_parameter = (*params->parameters)[i]; 1422 ParamDesc& existing_parameter = (*params->parameters)[i];
1418 if (existing_parameter.name->Equals(*parameter.name)) { 1423 if (existing_parameter.name->Equals(*parameter.name)) {
1419 ErrorMsg(parameter.name_pos, "duplicate formal parameter '%s'", 1424 ErrorMsg(parameter.name_pos, "duplicate formal parameter '%s'",
1420 parameter.name->ToCString()); 1425 parameter.name->ToCString());
1421 } 1426 }
1422 } 1427 }
(...skipping 8997 matching lines...) Expand 10 before | Expand all | Expand 10 after
10420 void Parser::SkipQualIdent() { 10425 void Parser::SkipQualIdent() {
10421 ASSERT(IsIdentifier()); 10426 ASSERT(IsIdentifier());
10422 ConsumeToken(); 10427 ConsumeToken();
10423 if (CurrentToken() == Token::kPERIOD) { 10428 if (CurrentToken() == Token::kPERIOD) {
10424 ConsumeToken(); // Consume the kPERIOD token. 10429 ConsumeToken(); // Consume the kPERIOD token.
10425 ExpectIdentifier("identifier expected after '.'"); 10430 ExpectIdentifier("identifier expected after '.'");
10426 } 10431 }
10427 } 10432 }
10428 10433
10429 } // namespace dart 10434 } // namespace dart
OLDNEW
« 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