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

Unified Diff: frog/gen.dart

Issue 8587021: fix initialization of null in loops (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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 | « frog/frogsh ('k') | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/gen.dart
diff --git a/frog/gen.dart b/frog/gen.dart
index 190ef53b48b859f36499038ad8bf90dac8e78bba..19028c73130d6d6bcf0d3f052e643359855e784f 100644
--- a/frog/gen.dart
+++ b/frog/gen.dart
@@ -1087,7 +1087,13 @@ class MethodGenerator implements TreeVisitor {
var val = _scope.create(name, thisType, node.names[i].span);
if (value == null) {
- writer.write('${val.code}');
+ if (_scope.reentrant) {
+ // To preserve block scoping, we need to ensure the variable is
+ // reinitialized each time the block is entered.
+ writer.write('${val.code} = null');
+ } else {
+ writer.write('${val.code}');
+ }
} else {
value = value.convertTo(this, type, node.values[i]);
writer.write('${val.code} = ${value.code}');
« no previous file with comments | « frog/frogsh ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698