Index: pkg/compiler/lib/src/parser/parser.dart |
diff --git a/pkg/compiler/lib/src/parser/parser.dart b/pkg/compiler/lib/src/parser/parser.dart |
index 821fcad03d8d64496ba4c78f3bc4c16fab8fa862..2ef5c5281260410f665f9049e4df34fe0666e156 100644 |
--- a/pkg/compiler/lib/src/parser/parser.dart |
+++ b/pkg/compiler/lib/src/parser/parser.dart |
@@ -429,8 +429,11 @@ class Parser { |
return token.next.next; |
} |
Lasse Reichstein Nielsen
2016/07/08 05:45:18
Is this `if` necessary now?
|
do { |
- ++parameterCount; |
token = token.next; |
+ if (optional(')', token)) { |
+ break; |
+ } |
+ ++parameterCount; |
String value = token.stringValue; |
if (identical(value, '[')) { |
token = parseOptionalFormalParameters(token, false); |
@@ -495,11 +498,23 @@ class Parser { |
int parameterCount = 0; |
do { |
token = token.next; |
+ if (isNamed && optional('}', token)) { |
+ break; |
+ } else if (!isNamed && optional(']', token)) { |
+ break; |
+ } |
var type = |
isNamed ? FormalParameterType.NAMED : FormalParameterType.POSITIONAL; |
token = parseFormalParameter(token, type); |
++parameterCount; |
} while (optional(',', token)); |
+ if (parameterCount == 0) { |
+ listener.reportError( |
+ token, |
+ isNamed |
+ ? MessageKind.EMPTY_NAMED_PARAMETER_LIST |
+ : MessageKind.EMPTY_OPTIONAL_PARAMETER_LIST); |
+ } |
listener.endOptionalFormalParameters(parameterCount, begin, token); |
if (isNamed) { |
return expect('}', token); |
@@ -2565,6 +2580,10 @@ class Parser { |
bool old = mayParseFunctionExpressions; |
mayParseFunctionExpressions = true; |
do { |
+ if (optional(')', token.next)) { |
+ token = token.next; |
+ break; |
+ } |
Token colon = null; |
if (optional(':', token.next.next)) { |
token = parseIdentifier(token.next); |