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

Unified Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 2774933002: Complain about uninitialized const fields. (Closed)
Patch Set: Created 3 years, 9 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 | tests/co19/co19-kernel.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | tests/co19/co19-kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698