-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathmessages.yaml
3626 lines (3054 loc) · 115 KB
/
messages.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
# Each entry in this map corresponds to a diagnostic message. Ideally, each
# entry contains three parts:
#
# 1. A message template (template).
#
# 2. A suggestion for how to correct the problem (tip).
#
# 3. Examples that produce the message (one of expression, statement,
# declaration, member, script, bytes or external). Note that 'external'
# should be the path to an external test. The external test will not be run,
# but the existance of the file will be verified.
#
# A message shouldn't indicate which kind of diagnostic it is, for example,
# warning or error. Tools are expected to prepend "Warning: ", or "Error: ",
# and should be allowed to change the kind of diagnostic without affecting the
# message. For example, an error might be turned into a warning by the tool.
#
# See the file [lib/src/fasta/diagnostics.md] for more details on how to write
# good diagnostic messages.
#
# A message used for internal errors should have key that starts with
# "InternalProblem". This way, UX review can prioritize it accordingly.
#
# Eventually, we'd like to have all diagnostics in one shared
# location. However, for now, the analyzer needs to translate error codes to
# its own format. To support this, an entry can contain an analyzer error code
# (analyzerCode).
#
# Long term, the analyzer and front-end need to share the same error codes. So
# eventually all error codes should have an `analyzerCode` field.
# Any error code with an `index` field and an `analyzerCode` field
# will be auto generated as an Analyzer error code.
# `index` field values should be unique, consecutive whole numbers starting with 1.
# If `index` is defined, then `analyzerCode` should be the fully formed
# name of the corresponding public Analyzer error const
# (e.g. ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND)
# which will be used when generating code in Analyzer for translating
# fasta error codes to Analyzer error codes.
#
# In some cases a mesage is internal to the frontend, and no meaningful
# analyzer code can be provided. In such cases set `frontendInternal: true`.
#
# ## Parameter Substitution in Template and Tip
#
# The fields `template` and `tip` are subject to parameter substitution. When
# the compiler reports a problem, it may also specify a map with the following
# keys to be substituted into the message:
#
# `#character` a Unicode character.
#
# `#unicode` a Unicode short identifier (U+xxxx). We use this to represent code
# units or code points.
#
# `#name`, `#name2`, `#name3`, `#name4`: names (as strings).
#
# `#names`: A list of names (strings).
#
# `#lexeme` a token. The token's `lexeme` property is used.
#
# `#string`, `#string2`, `#string3`: strings (that aren't names).
# Note: as a rule of thumb, avoid using the `#string` keys. In particular,
# do not use them for composing error messages, see [diagnostics.md](
# lib/src/fasta/diagnostics.md#avoid-composing-messages-programmatically).
#
# `#type`, #type2`, `#type3`: Kernel types.
#
# `#uri`, `#uri2`, `#uri3`: URIs.
#
# `#count`, `#count2`: counts (as integers)
#
# `#constant` a Kernel constant.
#
# `#num1%N.M`, `#num2%N.M`, `#num3%N.M`: numbers (doubles) formatted to minimum
# width N and with M fraction digits.
AsciiControlCharacter:
template: "The control character #unicode can only be used in strings and comments."
analyzerCode: ILLEGAL_CHARACTER
expression: "\x1b 1"
ConstEvalContext:
template: "While analyzing:"
ConstEvalDuplicateElement:
template: "The element '#constant' conflicts with another existing element in the set."
analyzerCode: EQUAL_ELEMENTS_IN_CONST_SET
ConstEvalDuplicateKey:
template: "The key '#constant' conflicts with another existing key in the map."
analyzerCode: EQUAL_KEYS_IN_CONST_MAP
ConstEvalElementImplementsEqual:
template: "The element '#constant' does not have a primitive operator '=='."
analyzerCode: CONST_SET_ELEMENT_TYPE_IMPLEMENTS_EQUALS
ConstEvalKeyImplementsEqual:
template: "The key '#constant' does not have a primitive operator '=='."
analyzerCode: CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
ConstEvalNonConstantLiteral:
template: "Can't have a non-constant #string literal within a const context."
analyzerCode: NON_CONSTANT_DEFAULT_VALUE
ConstEvalInvalidType:
template: "Expected constant '#constant' to be of type '#type', but was of type '#type2'."
ConstEvalInvalidBinaryOperandType:
template: "Binary operator '#string' on '#constant' requires operand of type '#type', but was of type '#type2'."
ConstEvalInvalidEqualsOperandType:
template: "Binary operator '==' requires receiver constant '#constant' of type 'Null', 'bool', 'int', 'double', or 'String', but was of type '#type'."
ConstEvalZeroDivisor:
template: "Binary operator '#string' on '#string2' requires non-zero divisor, but divisor was '0'."
analyzerCode: CONST_EVAL_THROWS_IDBZE
ConstEvalNegativeShift:
template: "Binary operator '#string' on '#string2' requires non-negative operand, but was '#string3'."
ConstEvalInvalidMethodInvocation:
template: "The method '#string' can't be invoked on '#constant' within a const context."
analyzerCode: UNDEFINED_OPERATOR
ConstEvalInvalidPropertyGet:
template: "The property '#string' can't be accessed on '#constant' within a const context."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalInvalidStringInterpolationOperand:
template: "The '#constant' can't be used as part of a string interpolation within a const context, only values of type 'null', 'bool', 'int', 'double', or 'String' can be used."
analyzerCode: CONST_EVAL_TYPE_BOOL_NUM_STRING
ConstEvalInvalidStaticInvocation:
template: "The invocation of '#name' is not allowed within a const context."
analyzerCode: CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
ConstEvalInvalidSymbolName:
template: "The symbol name must be a valid public Dart member name, public constructor name, or library name, optionally qualified, but was '#constant'."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalFailedAssertion:
template: "This assertion failed."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalFailedAssertionWithMessage:
template: "This assertion failed with message: #string"
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalNonConstantVariableGet:
template: "The variable '#string' is not a constant, only constant expressions are allowed."
analyzerCode: NON_CONSTANT_VALUE_IN_INITIALIZER
ConstEvalDeferredLibrary:
template: >
'#name' can't be used in a constant expression because it's marked as
'deferred' which means it isn't available until loaded.
tip: >
Try moving the constant from the deferred library, or removing 'deferred'
from the import.
analyzerCode: NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY
ConstEvalFreeTypeParameter:
template: "The type '#type' is not a constant because it depends on a type parameter, only instantiated types are allowed."
ConstEvalCircularity:
template: "Constant expression depends on itself."
analyzerCode: RECURSIVE_COMPILE_TIME_CONSTANT
ConstEvalNullValue:
template: "Null value during constant evaluation."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalNotListOrSetInSpread:
template: "Only lists and sets can be used in spreads in constant lists and sets."
analyzerCode: CONST_SPREAD_EXPECTED_LIST_OR_SET
ConstEvalNotMapInSpread:
template: "Only maps can be used in spreads in constant maps."
analyzerCode: CONST_SPREAD_EXPECTED_MAP
ConstEvalIterationInConstList:
template: "Iteration can't be used in a constant list."
analyzerCode: NON_CONSTANT_LIST_ELEMENT
ConstEvalIterationInConstSet:
template: "Iteration can't be used in a constant set."
analyzerCode: NON_CONSTANT_SET_ELEMENT
ConstEvalIterationInConstMap:
template: "Iteration can't be used in a constant map."
analyzerCode: NON_CONSTANT_MAP_ELEMENT
ConstEvalUnevaluated:
template: "Could not evaluate constant expression."
NotConstantExpression:
template: "#string is not a constant expression."
analyzerCode: NOT_CONSTANT_EXPRESSION
NotAConstantExpression:
template: "Not a constant expression."
analyzerCode: NOT_CONSTANT_EXPRESSION
NonAsciiIdentifier:
template: "The non-ASCII character '#character' (#unicode) can't be used in identifiers, only in strings and comments."
tip: "Try using an US-ASCII letter, a digit, '_' (an underscore), or '$' (a dollar sign)."
analyzerCode: ILLEGAL_CHARACTER
expression: "å"
NonAsciiWhitespace:
template: "The non-ASCII space character #unicode can only be used in strings and comments."
analyzerCode: ILLEGAL_CHARACTER
expression: "\u2028 1"
Encoding:
template: "Unable to decode bytes as UTF-8."
bytes: [255]
ExperimentNotEnabled:
index: 93
template: "This requires the '#string' experiment to be enabled."
tip: "Try enabling this experiment by adding it to the command line when compiling and running."
analyzerCode: ParserErrorCode.EXPERIMENT_NOT_ENABLED
EmptyNamedParameterList:
template: "Named parameter lists cannot be empty."
tip: "Try adding a named parameter to the list."
analyzerCode: "MISSING_IDENTIFIER"
script: >
foo({}) {}
main() {
foo();
}
EmptyOptionalParameterList:
template: "Optional parameter lists cannot be empty."
tip: "Try adding an optional parameter to the list."
analyzerCode: "MISSING_IDENTIFIER"
script: >
foo([]) {}
main() {
foo();
}
ExpectedElseOrComma:
index: 94
template: "Expected 'else' or comma."
analyzerCode: ParserErrorCode.EXPECTED_ELSE_OR_COMMA
ExpectedBlock:
template: "Expected a block."
tip: "Try adding {}."
analyzerCode: EXPECTED_TOKEN
script: "try finally {}"
ExpectedBlockToSkip:
template: "Expected a function body or '=>'."
# TODO(ahe): In some scenarios, we can suggest removing the 'static' keyword.
tip: "Try adding {}."
analyzerCode: MISSING_FUNCTION_BODY
script: "main();"
ExpectedBody:
template: "Expected a function body or '=>'."
# TODO(ahe): In some scenarios, we can suggest removing the 'static' keyword.
tip: "Try adding {}."
analyzerCode: MISSING_FUNCTION_BODY
script: "main();"
ExpectedStatement:
index: 29
template: "Expected a statement."
analyzerCode: ParserErrorCode.MISSING_STATEMENT
statement: "void;"
ExpectedButGot:
# Also see ExpectedAfterButGot and ExpectedInstead
template: "Expected '#string' before this."
# Consider the second example below: the parser expects a ')' before 'y', but
# a ',' would also have worked. We don't have enough information to give a
# good suggestion.
analyzerCode: EXPECTED_TOKEN
script:
- "main() => true ? 1;"
- "main() => foo(x: 1 y: 2);"
ExpectedAfterButGot:
# Also see ExpectedButGot and ExpectedInstead
template: "Expected '#string' after this."
# This is an alternative to ExpectedButGot when it's better for the error to be
# associated with the last consumed token rather than the token being parsed.
# Doing so can make it cognitively easier for the user to understand and fix.
#
# For example, this is ok...
#
# x = 7
# class Foo {
# ^^^^^
# Expected ';' before this
#
# but this is easier for the user...
#
# x = 7
# ^
# Expected ';' after this
# class Foo {
#
analyzerCode: EXPECTED_TOKEN
script:
- "main() { return true }"
ExpectedInstead:
# Also see ExpectedButGot and ExpectedAfterButGot
index: 41
template: "Expected '#string' instead of this."
# This is an alternative to ExpectedButGot when the last consumed token
# should be replaced with a different token.
#
# For example, this is ok...
#
# mixin Foo extends Bar {
# ^^^^^^^
# Expected 'on' before this
#
# but this is easier for the user...
#
# mixin Foo extends Bar {
# ^^^^^^^
# Expected 'on' instead of this
#
analyzerCode: ParserErrorCode.EXPECTED_INSTEAD
script:
- "mixin A extends B { }"
MultipleLibraryDirectives:
index: 27
template: "Only one library directive may be declared in a file."
tip: "Try removing all but one of the library directives."
analyzerCode: ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES
MultipleExtends:
index: 28
template: "Each class definition can have at most one extends clause."
tip: "Try choosing one superclass and define your class to implement (or mix in) the others."
analyzerCode: ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES
script: "class A extends B extends C {}"
MultipleWith:
index: 24
template: "Each class definition can have at most one with clause."
tip: "Try combining all of the with clauses into a single clause."
analyzerCode: ParserErrorCode.MULTIPLE_WITH_CLAUSES
script: "class A extends B with C, D with E {}"
WithBeforeExtends:
index: 11
template: "The extends clause must be before the with clause."
tip: "Try moving the extends clause before the with clause."
analyzerCode: ParserErrorCode.WITH_BEFORE_EXTENDS
script: "class B {} class A with B extends C {}"
ImplementsBeforeExtends:
index: 44
template: "The extends clause must be before the implements clause."
tip: "Try moving the extends clause before the implements clause."
analyzerCode: ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS
script: "class A implements B extends C {}"
ImplementsBeforeOn:
index: 43
template: "The on clause must be before the implements clause."
tip: "Try moving the on clause before the implements clause."
analyzerCode: ParserErrorCode.IMPLEMENTS_BEFORE_ON
script: "mixin A implements B on C {}"
ImplementsBeforeWith:
index: 42
template: "The with clause must be before the implements clause."
tip: "Try moving the with clause before the implements clause."
analyzerCode: ParserErrorCode.IMPLEMENTS_BEFORE_WITH
script: "class A extends B implements C with D {}"
ImplementsRepeated:
template: "'#name' can only be implemented once."
analyzerCode: IMPLEMENTS_REPEATED
tip: "Try removing #count of the occurrences."
script:
- >-
abstract class I {}
abstract class J {}
class K implements I, J, I {}
ImplementsSuperClass:
template: "'#name' can't be used in both 'extends' and 'implements' clauses."
analyzerCode: IMPLEMENTS_SUPER_CLASS
tip: "Try removing one of the occurrences."
script:
- >-
abstract class A {}
class C extends A implements A {}
MultipleImplements:
template: "Each class definition can have at most one implements clause."
tip: "Try combining all of the implements clauses into a single clause."
analyzerCode: MULTIPLE_IMPLEMENTS_CLAUSES
script: "class A implements B implements C, D {}"
MultipleOnClauses:
index: 26
template: "Each mixin definition can have at most one on clause."
tip: "Try combining all of the on clauses into a single clause."
analyzerCode: ParserErrorCode.MULTIPLE_ON_CLAUSES
script: "mixin A on B on C, D {}"
ImplementsFutureOr:
template: "'FutureOr' can't be used in an 'implements' clause."
script:
- >-
import 'dart:async';
class A implements FutureOr<int> {}
ExpectedClassOrMixinBody:
template: "Expected a class or mixin body, but got '#lexeme'."
analyzerCode: MISSING_CLASS_BODY
ExpectedClassBodyToSkip: ExpectedClassOrMixinBody
ExpectedDeclaration:
template: "Expected a declaration, but got '#lexeme'."
analyzerCode: EXPECTED_EXECUTABLE
ExpectedClassMember:
template: "Expected a class member, but got '#lexeme'."
analyzerCode: EXPECTED_CLASS_MEMBER
ExpectedFunctionBody:
template: "Expected a function body, but got '#lexeme'."
analyzerCode: MISSING_FUNCTION_BODY
ExpectedHexDigit:
template: "A hex digit (0-9 or A-F) must follow '0x'."
# No tip, seems obvious from the error message.
analyzerCode: MISSING_HEX_DIGIT
script: >
main() {
var i = 0x;
}
ExpectedIdentifier:
template: "Expected an identifier, but got '#lexeme'."
analyzerCode: MISSING_IDENTIFIER
script: "do() {} main() {}"
EqualityCannotBeEqualityOperand:
index: 1
template: "An equality expression can't be an operand of another equality expression."
tip: "Try re-writing the expression."
analyzerCode: ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND
script:
- "main() { var b = a < b < c; }"
- "main() { var b = a == b != c; }"
ExpectedOpenParens:
template: "Expected '('."
ExpectedString:
template: "Expected a String, but got '#lexeme'."
analyzerCode: EXPECTED_STRING_LITERAL
ExpectedToken:
template: "Expected to find '#string'."
analyzerCode: EXPECTED_TOKEN
ExpectedType:
template: "Expected a type, but got '#lexeme'."
analyzerCode: EXPECTED_TYPE_NAME
VarAsTypeName:
index: 61
template: "The keyword 'var' can't be used as a type name."
analyzerCode: ParserErrorCode.VAR_AS_TYPE_NAME
script:
- "class A { Map<String, var> m; }"
MissingExpressionInThrow:
index: 32
template: "Missing expression after 'throw'."
tip: "Add an expression after 'throw' or use 'rethrow' to throw a caught exception"
analyzerCode: ParserErrorCode.MISSING_EXPRESSION_IN_THROW
statement:
- "throw;"
MissingConstFinalVarOrType:
index: 33
template: "Variables must be declared using the keywords 'const', 'final', 'var' or a type name."
tip: "Try adding the name of the type of the variable or the keyword 'var'."
analyzerCode: ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
script:
- "class C { static f; }"
FunctionTypedParameterVar:
template: "Function-typed parameters can't specify 'const', 'final' or 'var' in place of a return type."
tip: "Try replacing the keyword with a return type."
analyzerCode: FUNCTION_TYPED_PARAMETER_VAR
script:
- "void f(const x()) {}"
- "void f(final x()) {}"
- "void f(var x()) {}"
AbstractClassMember:
index: 51
template: "Members of classes can't be declared to be 'abstract'."
tip: "Try removing the 'abstract' keyword. You can add the 'abstract' keyword before the class declaration."
analyzerCode: ParserErrorCode.ABSTRACT_CLASS_MEMBER
script:
- "abstract class C {abstract C.c();}"
- "abstract class C {abstract m();}"
- "abstract class C {abstract get m;}"
- "abstract class C {abstract set m(int x);}"
- "abstract class C {abstract f;}"
- "abstract class C {abstract static f;}"
ClassInClass:
index: 53
template: "Classes can't be declared inside other classes."
tip: "Try moving the class to the top-level."
analyzerCode: ParserErrorCode.CLASS_IN_CLASS
script:
- "class C { class B {} }"
EnumInClass:
index: 74
template: "Enums can't be declared inside classes."
tip: "Try moving the enum to the top-level."
analyzerCode: ParserErrorCode.ENUM_IN_CLASS
script:
- "class Foo { enum Bar { Bar1, Bar2, Bar3 } }"
TypedefInClass:
index: 7
template: "Typedefs can't be declared inside classes."
tip: "Try moving the typedef to the top-level."
analyzerCode: ParserErrorCode.TYPEDEF_IN_CLASS
script:
- "abstract class C { typedef int F(int x); }"
CovariantMember:
index: 67
template: "Getters, setters and methods can't be declared to be 'covariant'."
tip: "Try removing the 'covariant' keyword."
analyzerCode: ParserErrorCode.COVARIANT_MEMBER
script:
- "static covariant get x => 0;"
- "covariant int m() => 0;"
VarReturnType:
index: 12
template: "The return type can't be 'var'."
tip: "Try removing the keyword 'var', or replacing it with the name of the return type."
analyzerCode: ParserErrorCode.VAR_RETURN_TYPE
script:
- "class C { var m() {} }"
- "class C { var C() {} }"
ConstClass:
index: 60
template: "Classes can't be declared to be 'const'."
tip: "Try removing the 'const' keyword. If you're trying to indicate that instances of the class can be constants, place the 'const' keyword on the class' constructor(s)."
analyzerCode: ParserErrorCode.CONST_CLASS
script: "const class C {}"
ConstAndFinal:
index: 58
template: "Members can't be declared to be both 'const' and 'final'."
tip: "Try removing either the 'const' or 'final' keyword."
analyzerCode: ParserErrorCode.CONST_AND_FINAL
declaration:
- "class C { static const final int x = 5; }"
- "class C { static final const int x = 5; }"
- "const final int x = 5;"
- "final const int x = 5;"
ConflictingModifiers:
index: 59
template: "Members can't be declared to be both '#string' and '#string2'."
tip: "Try removing one of the keywords."
analyzerCode: ParserErrorCode.CONFLICTING_MODIFIERS
script:
- "class C { const var x; }"
- "class C { var const x; }"
ConstFactory:
index: 62
template: "Only redirecting factory constructors can be declared to be 'const'."
tip: "Try removing the 'const' keyword, or replacing the body with '=' followed by a valid target."
analyzerCode: ParserErrorCode.CONST_FACTORY
script:
- "class C { const factory C() {} }"
ConstFactoryRedirectionToNonConst:
template: "Constant factory constructor can't delegate to a non-constant constructor."
tip: "Try redirecting to a different constructor or marking the target constructor 'const'."
analyzerCode: REDIRECT_TO_NON_CONST_CONSTRUCTOR
script:
- >-
class A {
const factory A.foo() = A.bar;
A.bar() {}
}
NonConstFactory:
template: "Cannot invoke a non-'const' factory where a const expression is expected."
tip: "Try using a constructor or factory that is 'const'."
analyzerCode: NOT_CONSTANT_EXPRESSION
NonConstConstructor:
template: "Cannot invoke a non-'const' constructor where a const expression is expected."
tip: "Try using a constructor or factory that is 'const'."
analyzerCode: NOT_CONSTANT_EXPRESSION
ModifierOutOfOrder:
index: 56
template: "The modifier '#string' should be before the modifier '#string2'."
tip: "Try re-ordering the modifiers."
analyzerCode: ParserErrorCode.MODIFIER_OUT_OF_ORDER
script:
- "class C { factory const C() = prefix.B.foo; }"
TypeBeforeFactory:
index: 57
template: "Factory constructors cannot have a return type."
tip: "Try removing the type appearing before 'factory'."
analyzerCode: ParserErrorCode.TYPE_BEFORE_FACTORY
script:
- "class C { T factory C() { return null; } }"
ConstConstructorWithBody:
template: "A const constructor can't have a body."
tip: "Try removing either the 'const' keyword or the body."
analyzerCode: CONST_CONSTRUCTOR_WITH_BODY
script:
- "class C { const C() {} }"
ConstMethod:
index: 63
template: "Getters, setters and methods can't be declared to be 'const'."
tip: "Try removing the 'const' keyword."
analyzerCode: ParserErrorCode.CONST_METHOD
script:
- "class C { const m() {} }"
CovariantAfterVar:
index: 8
template: "The modifier 'covariant' should be before the modifier 'var'."
tip: "Try re-ordering the modifiers."
analyzerCode: ParserErrorCode.COVARIANT_AFTER_VAR
script:
- "var covariant f;"
CovariantAndStatic:
index: 66
template: "Members can't be declared to be both 'covariant' and 'static'."
tip: "Try removing either the 'covariant' or 'static' keyword."
analyzerCode: ParserErrorCode.COVARIANT_AND_STATIC
script:
- "class C { covariant static A f; }"
- "class C { static covariant A f; }"
DuplicatedModifier:
index: 70
template: "The modifier '#lexeme' was already specified."
tip: "Try removing all but one occurence of the modifier."
analyzerCode: ParserErrorCode.DUPLICATED_MODIFIER
script:
- "class C { const const m; }"
- "class C { external external f(); }"
- "class C { final final m = 5; }"
- "class C { static static var m; }"
- "class C { var var m; }"
ExternalAfterConst:
index: 46
template: "The modifier 'external' should be before the modifier 'const'."
tip: "Try re-ordering the modifiers."
analyzerCode: ParserErrorCode.EXTERNAL_AFTER_CONST
script:
- "class C { const external C(); }"
ExternalAfterFactory:
index: 47
template: "The modifier 'external' should be before the modifier 'factory'."
tip: "Try re-ordering the modifiers."
analyzerCode: ParserErrorCode.EXTERNAL_AFTER_FACTORY
script:
- "class C { factory external C(); }"
ExternalAfterStatic:
index: 48
template: "The modifier 'external' should be before the modifier 'static'."
tip: "Try re-ordering the modifiers."
analyzerCode: ParserErrorCode.EXTERNAL_AFTER_STATIC
script:
- "class C { static external f(); }"
ExternalConstructorWithBody:
index: 87
template: "External constructors can't have a body."
tip: "Try removing the body of the constructor, or removing the keyword 'external'."
analyzerCode: ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY
script:
- "class C { external C() {} }"
ExternalConstructorWithFieldInitializers:
template: "An external constructor can't initialize fields."
tip: "Try removing the field initializers, or removing the keyword 'external'."
analyzerCode: EXTERNAL_CONSTRUCTOR_WITH_FIELD_INITIALIZERS
ExternalFactoryWithBody:
index: 86
template: "External factories can't have a body."
tip: "Try removing the body of the factory, or removing the keyword 'external'."
analyzerCode: ParserErrorCode.EXTERNAL_FACTORY_WITH_BODY
script:
- "class C { external factory C() {} }"
ExternalField:
index: 50
template: "Fields can't be declared to be 'external'."
tip: "Try removing the keyword 'external'."
analyzerCode: ParserErrorCode.EXTERNAL_FIELD
script:
- "class C { external var f; }"
InitializerForStaticField:
template: "'#name' isn't an instance field of this class."
analyzerCode: INITIALIZER_FOR_STATIC_FIELD
InitializerOutsideConstructor:
template: "Only constructors can have initializers, and '#name' is not a constructor."
analyzerCode: INITIALIZER_OUTSIDE_CONSTRUCTOR
MoreThanOneSuperOrThisInitializer:
template: "Can't have more than one 'super' or 'this' initializer."
analyzerCode: SUPER_IN_REDIRECTING_CONSTRUCTOR
script:
- "class C { C.bad() : super(), super(); }"
- "class C { C(); C.bad() : super(), this(); }"
- "class C { C(); C.bad() : this(), super(); }"
- "class C { C(); C.bad() : this(), this(); }"
ThisInitializerNotAlone:
template: "Can't have other initializers together with 'this'."
analyzerCode: FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR
script:
- "class C { int x; C(); C.bad() : x = 5, this(); }"
- "class C { int x; C(); C.bad() : this(), x = 5; }"
SuperInitializerNotLast:
template: "Can't have initializers after 'super'."
analyzerCode: INVALID_SUPER_INVOCATION
script:
- "class C { int x; C.bad() : super(), x = 5; }"
ConstConstructorWithNonConstSuper:
template: "Constant constructor can't call non-constant super constructors."
analyzerCode: CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER
ExtraneousModifier:
index: 77
template: "Can't have modifier '#lexeme' here."
tip: "Try removing '#lexeme'."
analyzerCode: ParserErrorCode.EXTRANEOUS_MODIFIER
script:
- "var String foo; main(){}"
- "var set foo; main(){}"
- "var final foo; main(){}"
- "var var foo; main(){}"
- "var const foo; main(){}"
- "var abstract foo; main(){}"
- "var static foo; main(){}"
- "var external foo; main(){}"
- "get var foo; main(){}"
- "set var foo; main(){}"
- "final var foo; main(){}"
- "var var foo; main(){}"
- "const var foo; main(){}"
- "abstract var foo; main(){}"
- "static var foo; main(){}"
- "external var foo; main(){}"
- "set foo; main(){}"
- "abstract foo; main(){}"
- "static foo; main(){}"
- "external foo; main(){}"
- "final class C {}"
- "abstract enum foo {bar}"
- "abstract void foo() {}"
- "static void foo() {}"
- "abstract typedef foo();"
- "static typedef foo();"
FinalAndCovariant:
index: 80
template: "Members can't be declared to be both 'final' and 'covariant'."
tip: "Try removing either the 'final' or 'covariant' keyword."
analyzerCode: ParserErrorCode.FINAL_AND_COVARIANT
script:
- "class C { covariant final f = 5; }"
- "class C { final covariant f = 5; }"
FinalAndVar:
index: 81
template: "Members can't be declared to be both 'final' and 'var'."
tip: "Try removing the keyword 'var'."
analyzerCode: ParserErrorCode.FINAL_AND_VAR
script:
- "class C { final var x = 5; }"
- "class C { var final x = 5; }"
StaticAfterConst:
index: 20
template: "The modifier 'static' should be before the modifier 'const'."
tip: "Try re-ordering the modifiers."
analyzerCode: ParserErrorCode.STATIC_AFTER_CONST
script:
- "class C { const static int f; }"
StaticAfterFinal:
index: 19
template: "The modifier 'static' should be before the modifier 'final'."
tip: "Try re-ordering the modifiers."
analyzerCode: ParserErrorCode.STATIC_AFTER_FINAL
script:
- "class C { final static int f = 5; }"
StaticAfterVar:
index: 18
template: "The modifier 'static' should be before the modifier 'var'."
tip: "Try re-ordering the modifiers."
analyzerCode: ParserErrorCode.STATIC_AFTER_VAR
script:
- "class C { var static f; }"
StaticConstructor:
index: 4
template: "Constructors can't be static."
tip: "Try removing the keyword 'static'."
analyzerCode: ParserErrorCode.STATIC_CONSTRUCTOR
script:
- "class C { static C() {} }"
- "class C { static C.m() {} }"
StaticOperator:
index: 17
template: "Operators can't be static."
tip: "Try removing the keyword 'static'."
analyzerCode: ParserErrorCode.STATIC_OPERATOR
script:
- "class C { static operator +(int x) => x + 1; }"
BreakOutsideOfLoop:
index: 52
template: "A break statement can't be used outside of a loop or switch statement."
tip: "Try removing the break statement."
analyzerCode: ParserErrorCode.BREAK_OUTSIDE_OF_LOOP
script:
- "main() { break; }"
InvalidBreakTarget:
template: "Can't break to '#name'."
BreakTargetOutsideFunction:
template: "Can't break to '#name' in a different function."
analyzerCode: LABEL_IN_OUTER_SCOPE
statement: |
label: while (true) {
void f() {
while (true) {
break label;
}
}
}
AnonymousBreakTargetOutsideFunction:
template: "Can't break to a target in a different function."
analyzerCode: LABEL_IN_OUTER_SCOPE
statement: |
while (true) {
void f() {
break;
}
}
ContinueOutsideOfLoop:
index: 2
template: "A continue statement can't be used outside of a loop or switch statement."
tip: "Try removing the continue statement."
analyzerCode: ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP
script:
- "main() { continue; }"
InvalidContinueTarget:
template: "Can't continue at '#name'."
ContinueTargetOutsideFunction:
template: "Can't continue at '#name' in a different function."
analyzerCode: LABEL_IN_OUTER_SCOPE
statement: |
label: while (true) {
void f() {
while (true) {
continue label;
}
}
}
AnonymousContinueTargetOutsideFunction:
template: "Can't continue at a target in a different function."
analyzerCode: LABEL_IN_OUTER_SCOPE
statement: |
while (true) {
void f() {
continue;
}
}
ContinueLabelNotTarget:
template: "Target of continue must be a label."
analyzerCode: LABEL_UNDEFINED
ContinueWithoutLabelInCase:
index: 64
template: "A continue statement in a switch statement must have a label as a target."
tip: "Try adding a label associated with one of the case clauses to the continue statement."
analyzerCode: ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE
script:
- "main() { switch (x) {case 1: continue;} }"
DuplicateLabelInSwitchStatement:
index: 72
template: "The label '#name' was already used in this switch statement."
tip: "Try choosing a different name for this label."
analyzerCode: ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT
statement:
- "switch (0) {l1: case 0: break; l1: case 1: break;}"
LabelNotFound:
template: "Can't find label '#name'."
tip: "Try defining the label, or correcting the name to match an existing label."
analyzerCode: LABEL_UNDEFINED
statement:
- "switch (0) {case 0: continue L;}"
InitializedVariableInForEach:
index: 82
template: "The loop variable in a for-each loop can't be initialized."
tip: "Try removing the initializer, or using a different kind of loop."
analyzerCode: ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH
statement:
- "for (int a = 0 in <int>[10]) {}"
InvalidAwaitFor:
index: 9
template: "The keyword 'await' isn't allowed for a normal 'for' statement."
tip: "Try removing the keyword, or use a for-each statement."
analyzerCode: ParserErrorCode.INVALID_AWAIT_IN_FOR
script:
- "f() async {await for (int i = 0; i < 5; i++) {}}"
InvalidSyncModifier:
template: "Invalid modifier 'sync'."
tip: "Try replacing 'sync' with 'sync*'."
analyzerCode: MISSING_STAR_AFTER_SYNC
script: "main() sync {}"
InvalidVoid:
template: "Type 'void' can't be used here because it isn't a return type."
tip: "Try removing 'void' keyword or replace it with 'var', 'final', or a type."
analyzerCode: EXPECTED_TYPE_NAME
script:
- "void x; main() {}"
- "foo(void x) {} main() { foo(null); }"
# TODO(danrubel): Review where this error is generated and consider generating
# FieldInitializedOutsideDeclaringClass instead of this in some situations.
InvalidInitializer:
template: "Not a valid initializer."
tip: "To initialize a field, use the syntax 'name = value'."
FieldInitializedOutsideDeclaringClass:
index: 88
template: "A field can only be initialized in it's declaring class"
tip: "Try passing a value into the superclass constructor, or moving the initialization into the constructor body."
analyzerCode: ParserErrorCode.FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS
script:
- "class A { int a; } class C extends A { C() : super.a = 42; }"