Chromium Code Reviews| Index: pkg/kernel/lib/verifier.dart |
| diff --git a/pkg/kernel/lib/verifier.dart b/pkg/kernel/lib/verifier.dart |
| index 5de5288050a1f34662a64a0b0d64b456eb98626d..7ad90111131d19d245e1bb20c3b2fc4a759a7ea1 100644 |
| --- a/pkg/kernel/lib/verifier.dart |
| +++ b/pkg/kernel/lib/verifier.dart |
| @@ -51,6 +51,8 @@ class VerifyingVisitor extends RecursiveVisitor { |
| /// attempt to validate constructor initializers. |
| bool isOutline = false; |
| + bool inCatchBlock = false; |
| + |
| Member currentMember; |
| Class currentClass; |
| TreeNode currentParent; |
| @@ -272,10 +274,34 @@ class VerifyingVisitor extends RecursiveVisitor { |
| } |
| visitCatch(Catch node) { |
| + bool savedinCatchBlock = inCatchBlock; |
| + inCatchBlock = true; |
| visitWithLocalScope(node); |
| + inCatchBlock = savedinCatchBlock; |
|
asgerf
2017/04/07 08:52:52
Also save and set to false in visitFunctionNode.
ahe
2017/04/07 10:43:39
Good point. I know another file where I need to do
|
| + } |
| + |
| + @override |
| + visitRethrow(Rethrow node) { |
| + if (!inCatchBlock) { |
| + problem(node, "Rethrow must be inside a Catch block."); |
| + } |
| } |
| visitVariableDeclaration(VariableDeclaration node) { |
| + var parent = node.parent; |
| + if (parent is! Block && |
| + !(parent is Catch && parent.body != node) && |
| + !(parent is FunctionNode && parent.body != node) && |
| + parent is! FunctionDeclaration && |
| + !(parent is ForStatement && parent.body != node) && |
| + !(parent is ForInStatement && parent.body != node) && |
| + parent is! Let && |
| + parent is! LocalInitializer) { |
| + problem( |
| + node, |
| + "VariableDeclaration must be a direct child of a Block, " |
| + "not ${parent.runtimeType}."); |
| + } |
| visitChildren(node); |
| declareVariable(node); |
| } |