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

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

Issue 10917070: Disallow legacy try-catch syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge. 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/warnings.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 babe22f3ad7b2bebbba343c9e12096a9f5782d1e..cb64261ed70514080d37932f914f4ef999c69203 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -1846,7 +1846,7 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
}
visitCatchBlock(CatchBlock node) {
- Scope blockScope = new BlockScope(scope);
+ // 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()
@@ -1855,6 +1855,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);
« no previous file with comments | « no previous file | lib/compiler/implementation/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698