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

Unified Diff: lib/compiler/implementation/resolver.dart

Issue 10905203: Allow catch part to be optional as in try {} on T [catch (x[,y])] {} (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/compiler/implementation/scanner/listener.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index b1c3710b52f9b888f69b25ceccbc9ef1fd3c1fa7..3f982af889d169fbf52283738f7eb36f1010c77a 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -1907,34 +1907,38 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
}
visitCatchBlock(CatchBlock node) {
- // Check that the catch has one or two formal parameters.
- if (node.formals.isEmpty()) {
- error(node, MessageKind.EMPTY_CATCH_DECLARATION);
- } else if (!node.formals.nodes.tail.isEmpty()
- && !node.formals.nodes.tail.tail.isEmpty()) {
- for (Node extra in node.formals.nodes.tail.tail) {
- error(extra, MessageKind.EXTRA_CATCH_DECLARATION);
+ // Check that if catch part is present, then
+ // it has one or two formal parameters.
+ if (node.formals !== null) {
+ if (node.formals.isEmpty()) {
+ error(node, MessageKind.EMPTY_CATCH_DECLARATION);
+ }
+ if (!node.formals.nodes.tail.isEmpty() &&
+ !node.formals.nodes.tail.tail.isEmpty()) {
+ for (Node extra in node.formals.nodes.tail.tail) {
+ 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 {
+ // 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);
+ 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);
+ }
}
}
}
« no previous file with comments | « no previous file | lib/compiler/implementation/scanner/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698