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

Unified Diff: pkg/compiler/lib/src/resolution/variables.dart

Issue 1503063002: Handle const loop variable. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years 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 | « pkg/compiler/lib/src/resolution/members.dart ('k') | tests/language/const_for_in_variable_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/variables.dart
diff --git a/pkg/compiler/lib/src/resolution/variables.dart b/pkg/compiler/lib/src/resolution/variables.dart
index 6f22eed3214167ac8b1f69657f4b30f15930e2b8..aec67f3afdf3d20e9bbd105ed962184c4e2af013 100644
--- a/pkg/compiler/lib/src/resolution/variables.dart
+++ b/pkg/compiler/lib/src/resolution/variables.dart
@@ -60,11 +60,16 @@ class VariableDefinitionsVisitor extends CommonResolverVisitor<Identifier> {
registry.registerTypeUse(
new TypeUse.instantiation(compiler.coreTypes.nullType));
if (definitions.modifiers.isConst) {
- reporter.reportErrorMessage(
- node, MessageKind.CONST_WITHOUT_INITIALIZER);
+ if (resolver.inLoopVariable) {
+ reporter.reportErrorMessage(
+ node, MessageKind.CONST_LOOP_VARIABLE);
+ } else {
+ reporter.reportErrorMessage(
+ node, MessageKind.CONST_WITHOUT_INITIALIZER);
+ }
}
if (definitions.modifiers.isFinal &&
- !resolver.allowFinalWithoutInitializer) {
+ !resolver.inLoopVariable) {
reporter.reportErrorMessage(
node, MessageKind.FINAL_WITHOUT_INITIALIZER);
}
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | tests/language/const_for_in_variable_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698