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

Unified Diff: pkg/compiler/lib/src/js/rewrite_async.dart

Issue 948353002: Initialize "next" variable in async rewrite whenever there is a finally. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comment. Created 5 years, 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js/rewrite_async.dart
diff --git a/pkg/compiler/lib/src/js/rewrite_async.dart b/pkg/compiler/lib/src/js/rewrite_async.dart
index bb8739483e4c802437cac9506fb8771371296a1f..d51e44e9aaf787c54b8055b692050bb78b75712d 100644
--- a/pkg/compiler/lib/src/js/rewrite_async.dart
+++ b/pkg/compiler/lib/src/js/rewrite_async.dart
@@ -360,9 +360,6 @@ class AsyncRewriter extends js.NodeVisitor {
/// True if the function has any try blocks containing await.
bool hasTryBlocks = false;
- /// True if any return, break or continue passes through a finally.
- bool hasJumpThroughFinally = false;
-
/// True if the traversion currently is inside a loop or switch for which
/// [shouldTransform] is false.
bool insideUntranslatedBreakable = false;
@@ -845,7 +842,7 @@ class AsyncRewriter extends js.NodeVisitor {
}
inits.add(makeInit(handlerName, js.number(rethrowLabel)));
inits.add(makeInit(currentErrorName, null));
- if (hasJumpThroughFinally || analysis.hasYield) {
+ if (analysis.hasFinally || (isAsyncStar && analysis.hasYield)) {
inits.add(makeInit(nextName, null));
}
if (isAsyncStar && analysis.hasYield) {
@@ -1176,7 +1173,6 @@ class AsyncRewriter extends js.NodeVisitor {
// now.
int firstTarget = jumpStack.removeLast();
if (jumpStack.isNotEmpty) {
- hasJumpThroughFinally = true;
js.Expression jsJumpStack = new js.ArrayInitializer(
jumpStack.map((int label) => js.number(label)).toList());
addStatement(js.js.statement("# = #", [nextName, jsJumpStack]));
@@ -1905,6 +1901,8 @@ class PreTranslationAnalysis extends js.NodeVisitor<bool> {
bool hasYield = false;
+ bool hasFinally = false;
+
// The function currently being analyzed.
js.Fun currentFunction;
@@ -2260,6 +2258,7 @@ class PreTranslationAnalysis extends js.NodeVisitor<bool> {
bool catchPart = (node.catchPart == null) ? false : visit(node.catchPart);
bool finallyPart =
(node.finallyPart == null) ? false : visit(node.finallyPart);
+ if (finallyPart != null) hasFinally = true;
return body || catchPart || finallyPart;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698