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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/co19/co19-kernel.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library fasta.body_builder; 5 library fasta.body_builder;
6 6
7 import '../parser/parser.dart' show FormalParameterType, optional; 7 import '../parser/parser.dart' show FormalParameterType, optional;
8 8
9 import '../parser/error_kind.dart' show ErrorKind; 9 import '../parser/error_kind.dart' show ErrorKind;
10 10
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 @override 971 @override
972 void endFieldInitializer(Token assignmentOperator) { 972 void endFieldInitializer(Token assignmentOperator) {
973 debugEvent("FieldInitializer"); 973 debugEvent("FieldInitializer");
974 assert(assignmentOperator.stringValue == "="); 974 assert(assignmentOperator.stringValue == "=");
975 push(popForValue()); 975 push(popForValue());
976 } 976 }
977 977
978 @override 978 @override
979 void handleNoFieldInitializer(Token token) { 979 void handleNoFieldInitializer(Token token) {
980 debugEvent("NoFieldInitializer"); 980 debugEvent("NoFieldInitializer");
981 push(NullValue.FieldInitializer); 981 if (constantExpressionRequired) {
982 addCompileTimeError(
983 token.charOffset, "const field must have initializer.");
984 // Creating a null value to prevent the Dart VM from crashing.
985 push(new NullLiteral()..fileOffset = token.charOffset);
986 } else {
987 push(NullValue.FieldInitializer);
988 }
982 } 989 }
983 990
984 @override 991 @override
985 void endInitializedIdentifier(Token nameToken) { 992 void endInitializedIdentifier(Token nameToken) {
986 // TODO(ahe): Use [InitializedIdentifier] here? 993 // TODO(ahe): Use [InitializedIdentifier] here?
987 debugEvent("InitializedIdentifier"); 994 debugEvent("InitializedIdentifier");
988 VariableDeclaration variable = pop(); 995 VariableDeclaration variable = pop();
989 variable.fileOffset = nameToken.charOffset; 996 variable.fileOffset = nameToken.charOffset;
990 push(variable); 997 push(variable);
991 scope[variable.name] = new KernelVariableBuilder( 998 scope[variable.name] = new KernelVariableBuilder(
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after
2857 } else if (node is PrefixBuilder) { 2864 } else if (node is PrefixBuilder) {
2858 return node.name; 2865 return node.name;
2859 } else if (node is ThisAccessor) { 2866 } else if (node is ThisAccessor) {
2860 return node.isSuper ? "super" : "this"; 2867 return node.isSuper ? "super" : "this";
2861 } else if (node is BuilderAccessor) { 2868 } else if (node is BuilderAccessor) {
2862 return node.plainNameForRead; 2869 return node.plainNameForRead;
2863 } else { 2870 } else {
2864 return internalError("Unhandled: ${node.runtimeType}"); 2871 return internalError("Unhandled: ${node.runtimeType}");
2865 } 2872 }
2866 } 2873 }
OLDNEW
« 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