Index: pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
index 99d52df96e4e934f17d9a0273722e96a9d053a75..98c470af7236bc1b971c18bdb0ed509822aeb2c2 100644 |
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
@@ -978,7 +978,14 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
@override |
void handleNoFieldInitializer(Token token) { |
debugEvent("NoFieldInitializer"); |
- push(NullValue.FieldInitializer); |
+ if (constantExpressionRequired) { |
+ addCompileTimeError( |
+ token.charOffset, "const field must have initializer."); |
+ // Creating a null value to prevent the Dart VM from crashing. |
+ push(new NullLiteral()..fileOffset = token.charOffset); |
+ } else { |
+ push(NullValue.FieldInitializer); |
+ } |
} |
@override |