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

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

Issue 11049023: [dart2js] Report an error if throw is used outside of catch expression without an argument. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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/ssa/builder.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 91144c07a22cd284f7bdfb17509ae102bff710a9..2e96dc00a63159e00123c75c8930762cef083154 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -1029,6 +1029,7 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
final TypeResolver typeResolver;
bool inInstanceContext;
bool inCheckContext;
+ bool inCatchBlock;
Scope scope;
ClassElement currentClass;
ExpressionStatement currentExpressionStatement;
@@ -1050,6 +1051,7 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
typeResolver = new TypeResolver(compiler),
scope = element.buildScope(),
inCheckContext = compiler.enableTypeAssertions,
+ inCatchBlock = false,
super(compiler);
Enqueuer get world => compiler.enqueuer.resolution;
@@ -1682,6 +1684,9 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
}
visitThrow(Throw node) {
+ if (!inCatchBlock && node.expression === null) {
+ error(node, MessageKind.THROW_WITHOUT_EXPRESSION);
+ }
visit(node.expression);
}
@@ -2111,7 +2116,10 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
doInCheckContext(() => visitIn(node.type, blockScope));
typeRequired = wasTypeRequired;
visitIn(node.formals, blockScope);
+ var oldInCatchBlock = inCatchBlock;
+ inCatchBlock = true;
visitIn(node.block, blockScope);
+ inCatchBlock = oldInCatchBlock;
}
visitTypedef(Typedef node) {
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698