Chromium Code Reviews| Index: lib/compiler/implementation/resolver.dart |
| diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart |
| index 0b4f69e05603052d1ff173e98d0f00506fac5328..1dab660aa159f053b2e50bd748614dd015b255f3 100644 |
| --- a/lib/compiler/implementation/resolver.dart |
| +++ b/lib/compiler/implementation/resolver.dart |
| @@ -1834,7 +1834,7 @@ class ResolverVisitor extends CommonResolverVisitor<Element> { |
| } |
| visitCatchBlock(CatchBlock node) { |
| - Scope blockScope = new BlockScope(scope); |
| + // Check that the catch have one or two formal parameters. |
|
karlklose
2012/09/04 10:27:02
'have' -> 'has'.
|
| if (node.formals.isEmpty()) { |
| error(node, MessageKind.EMPTY_CATCH_DECLARATION); |
| } else if (!node.formals.nodes.tail.isEmpty() |
| @@ -1843,6 +1843,30 @@ class ResolverVisitor extends CommonResolverVisitor<Element> { |
| error(extra, MessageKind.EXTRA_CATCH_DECLARATION); |
| } |
| } |
| + |
| + // Check that the formals aren't optional and that they have no |
| + // modifiers or type. |
| + for (Link<Node> link = node.formals.nodes; |
| + !link.isEmpty(); |
| + link = link.tail) { |
| + // If the formal parameter is a node list, it means that it is a |
| + // sequence of optional parameters. |
| + NodeList nodeList = link.head.asNodeList(); |
| + if (nodeList !== null) { |
| + error(nodeList, MessageKind.OPTIONAL_PARAMETER_IN_CATCH); |
| + } else { |
| + VariableDefinitions declaration = link.head; |
| + for (Node modifier in declaration.modifiers.nodes) { |
| + error(modifier, MessageKind.PARAMETER_WITH_MODIFIER_IN_CATCH); |
| + } |
| + TypeAnnotation type = declaration.type; |
| + if (type !== null) { |
| + error(type, MessageKind.PARAMETER_WITH_TYPE_IN_CATCH); |
| + } |
| + } |
| + } |
| + |
| + Scope blockScope = new BlockScope(scope); |
| visitIn(node.type, blockScope); |
| visitIn(node.formals, blockScope); |
| visitIn(node.block, blockScope); |