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

Unified Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 11446009: Report compile time error if named argument is given twice. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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-dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/resolution/members.dart
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
index d30753dff35e6085cc95390c894ce77d827477dd..39c3cd901eea0253817e9b22ac988bca5ba46da0 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -1771,13 +1771,19 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
void resolveArguments(NodeList list) {
if (list == null) return;
- bool seenNamedArgument = false;
+ List<SourceString> seenNamedArguments = <SourceString>[];
for (Link<Node> link = list.nodes; !link.isEmpty; link = link.tail) {
Expression argument = link.head;
visit(argument);
- if (argument.asNamedArgument() != null) {
- seenNamedArgument = true;
- } else if (seenNamedArgument) {
+ NamedArgument namedArgument = argument.asNamedArgument();
+ if (namedArgument != null) {
+ SourceString source = namedArgument.name.source;
+ if (seenNamedArguments.contains(source)) {
+ error(argument, MessageKind.DUPLICATE_DEFINITION,
+ [source.slowToString()]);
+ }
+ seenNamedArguments.add(source);
+ } else if (!seenNamedArguments.isEmpty) {
error(argument, MessageKind.INVALID_ARGUMENT_AFTER_NAMED);
}
}
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698