/
messages.yaml
7358 lines (6192 loc) · 251 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.
# Run
#
# dart run pkg/front_end/tool/_fasta/generate_messages.dart
#
# to regenerate messages after having edited this file.
#
# If entries with 'analyzerCode', 'sharedName', or 'index' have been changed,
# run
#
# dart run pkg/analyzer/tool/messages/generate.dart
#
# to regenerate analyzer messages.
# Each entry in this map corresponds to a diagnostic message. Ideally, each
# entry contains three parts:
#
# 1. A message template (problemMessage).
#
# 2. A suggestion for how to correct the problem (correctionMessage).
#
# 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 existence of the file will be verified.
#
# Multiple scripts can start with a `// @dart=` annotation to enforce the
# language version used for the example code.
#
# Note that it can be hard or impossible to write an example that only gives the
# specific error. To allow for this, one can specify
# "exampleAllowMoreCodes: true" which filters out every message with a
# different code, and just verifies we got exactly one message of the code in
# question (in addition too different codes).
#
# 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.
# If `sharedName` is defined, the generated analyzer code will use this as the
# user-facing analyzer code instead of `analyzerCode`. Multiple messages can share
# the `sharedName`.
#
# Errors with an `index` can also optionally contain user-facing documentation
# for the problem (documentation), which will be extracted to
# `pkg/analyzer/tool/diagnostics/diagnostics.md`, as well as internal
# documentation (comment), which will be included in the code generated for the
# analyzer.
#
# In some cases a message is internal to the frontend, and no meaningful
# analyzer code can be provided. In such cases set `frontendInternal: true`.
#
# ## Parameter Substitution in problemMessage and correctionMessage
#
# The fields `problemMessage` and `correctionMessage` 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). Note that asserts
# check if these are empty. If they can be empty use an available `OKEmpty`
# version (or add the missing needed one(s)) to avoid triggering an assert.
#
# `#nameOKEmpty`: name (as string). Will use an "(unnamed)" default message if
# the string is null or empty. Otherwise see the description above.
#
# `#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).
# Note that asserts check if these are empty. If they can be empty use an
# available `OKEmpty` version (or add the missing needed one(s)) to avoid
# triggering an assert.
#
# `#stringOKEmpty`: string (that isn't a name). Will use an "(empty)" default
# message if the string is null or empty.
# Otherwise see the description above.
#
# `#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:
problemMessage: "The control character #unicode can only be used in strings and comments."
analyzerCode: ILLEGAL_CHARACTER
expression: "\x1b 1"
ConstEvalStartingPoint:
problemMessage: "Constant evaluation error:"
ConstEvalContext:
problemMessage: "While analyzing:"
ConstEvalDuplicateElement:
problemMessage: "The element '#constant' conflicts with another existing element in the set."
analyzerCode: EQUAL_ELEMENTS_IN_CONST_SET
ConstEvalDuplicateKey:
problemMessage: "The key '#constant' conflicts with another existing key in the map."
analyzerCode: EQUAL_KEYS_IN_CONST_MAP
ConstEvalElementImplementsEqual:
problemMessage: "The element '#constant' does not have a primitive operator '=='."
analyzerCode: CONST_SET_ELEMENT_TYPE_IMPLEMENTS_EQUALS
ConstEvalElementNotPrimitiveEquality:
problemMessage: "The element '#constant' does not have a primitive equality."
ConstEvalKeyImplementsEqual:
problemMessage: "The key '#constant' does not have a primitive operator '=='."
analyzerCode: CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
ConstEvalKeyNotPrimitiveEquality:
problemMessage: "The key '#constant' does not have a primitive equality."
ConstEvalCaseImplementsEqual:
problemMessage: "Case expression '#constant' does not have a primitive operator '=='."
ConstEvalInvalidType:
problemMessage: "Expected constant '#constant' to be of type '#type', but was of type '#type2'."
ConstEvalInvalidBinaryOperandType:
problemMessage: "Binary operator '#stringOKEmpty' on '#constant' requires operand of type '#type', but was of type '#type2'."
ConstEvalInvalidEqualsOperandType:
problemMessage: "Binary operator '==' requires receiver constant '#constant' of type 'Null', 'bool', 'int', 'double', or 'String', but was of type '#type'."
ConstEvalEqualsOperandNotPrimitiveEquality:
problemMessage: "Binary operator '==' requires receiver constant '#constant' of a type with primitive equality or type 'double', but was of type '#type'."
ConstEvalZeroDivisor:
problemMessage: "Binary operator '#string' on '#string2' requires non-zero divisor, but divisor was '0'."
analyzerCode: CONST_EVAL_THROWS_IDBZE
ConstEvalNegativeShift:
problemMessage: "Binary operator '#string' on '#string2' requires non-negative operand, but was '#string3'."
ConstEvalTruncateError:
problemMessage: "Binary operator '#string ~/ #string2' results is Infinity or NaN."
ConstEvalNonNull:
problemMessage: "Constant expression must be non-null."
ConstEvalGetterNotFound:
problemMessage: "Variable get not found: '#nameOKEmpty'"
ConstEvalInvalidMethodInvocation:
problemMessage: "The method '#stringOKEmpty' can't be invoked on '#constant' in a constant expression."
analyzerCode: UNDEFINED_OPERATOR
ConstEvalInvalidPropertyGet:
problemMessage: "The property '#stringOKEmpty' can't be accessed on '#constant' in a constant expression."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalInvalidRecordIndexGet:
problemMessage: "The property '#stringOKEmpty' can't be accessed on '#constant' in a constant expression."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalInvalidRecordNameGet:
problemMessage: "The property '#stringOKEmpty' can't be accessed on '#constant' in a constant expression."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalInvalidStringInterpolationOperand:
problemMessage: |
The constant value '#constant' can't be used as part of a string interpolation in a constant expression.
Only values of type 'null', 'bool', 'int', 'double', or 'String' can be used.
analyzerCode: CONST_EVAL_TYPE_BOOL_NUM_STRING
ConstEvalInvalidStaticInvocation:
problemMessage: "The invocation of '#nameOKEmpty' is not allowed in a constant expression."
analyzerCode: CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
ConstEvalInvalidSymbolName:
problemMessage: "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:
problemMessage: "This assertion failed."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalFailedAssertionWithMessage:
problemMessage: "This assertion failed with message: #stringOKEmpty"
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalFailedAssertionWithNonStringMessage:
problemMessage: "This assertion failed with a non-String message."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalNonConstantVariableGet:
problemMessage: "The variable '#nameOKEmpty' is not a constant, only constant expressions are allowed."
analyzerCode: NON_CONSTANT_VALUE_IN_INITIALIZER
ConstEvalDeferredLibrary:
problemMessage: >
'#nameOKEmpty' can't be used in a constant expression because it's marked as
'deferred' which means it isn't available until loaded.
correctionMessage: >
Try moving the constant from the deferred library, or removing 'deferred'
from the import.
analyzerCode: INVALID_ANNOTATION_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY
ConstEvalFreeTypeParameter:
problemMessage: "The type '#type' is not a constant because it depends on a type parameter, only instantiated types are allowed."
ConstEvalCircularity:
problemMessage: "Constant expression depends on itself."
analyzerCode: RECURSIVE_COMPILE_TIME_CONSTANT
ConstEvalNullValue:
problemMessage: "Null value during constant evaluation."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalNotListOrSetInSpread:
problemMessage: "Only lists and sets can be used in spreads in constant lists and sets."
analyzerCode: CONST_SPREAD_EXPECTED_LIST_OR_SET
ConstEvalNotMapInSpread:
problemMessage: "Only maps can be used in spreads in constant maps."
analyzerCode: CONST_SPREAD_EXPECTED_MAP
ConstEvalExtension:
problemMessage: "Extension operations can't be used in constant expressions."
analyzerCode: NOT_CONSTANT_EXPRESSION
ConstEvalExternalConstructor:
problemMessage: "External constructors can't be evaluated in constant expressions."
ConstEvalExternalFactory:
problemMessage: "External factory constructors can't be evaluated in constant expressions."
ConstEvalUnevaluated:
problemMessage: "Couldn't evaluate constant expression."
ConstEvalError:
problemMessage: "Error evaluating constant expression: #string"
ConstEvalUnhandledCoreException:
problemMessage: "Unhandled core exception: #stringOKEmpty"
ConstEvalUnhandledException:
problemMessage: "Unhandled exception: #constant"
NotConstantExpression:
problemMessage: "#string is not a constant expression."
analyzerCode: NOT_CONSTANT_EXPRESSION
NotAConstantExpression:
problemMessage: "Not a constant expression."
analyzerCode: NOT_CONSTANT_EXPRESSION
MissingExplicitConst:
problemMessage: "Constant expression expected."
correctionMessage: "Try inserting 'const'."
analyzerCode: NOT_CONSTANT_EXPRESSION
script: >
class A {
final x;
const A(): x = [];
}
NonAsciiIdentifier:
problemMessage: "The non-ASCII character '#character' (#unicode) can't be used in identifiers, only in strings and comments."
correctionMessage: "Try using an US-ASCII letter, a digit, '_' (an underscore), or '$' (a dollar sign)."
analyzerCode: ILLEGAL_CHARACTER
expression: "å"
NonAsciiWhitespace:
problemMessage: "The non-ASCII space character #unicode can only be used in strings and comments."
analyzerCode: ILLEGAL_CHARACTER
expression: "\u2028 1"
Encoding:
problemMessage: "Unable to decode bytes as UTF-8."
bytes: [255]
ExperimentNotEnabled:
index: 48
problemMessage: "This requires the '#string' language feature to be enabled."
correctionMessage: "Try updating your pubspec.yaml to set the minimum SDK constraint to #string2 or higher, and running 'pub get'."
analyzerCode: ParserErrorCode.EXPERIMENT_NOT_ENABLED
ExperimentNotEnabledOffByDefault:
index: 133
problemMessage: "This requires the experimental '#string' language feature to be enabled."
correctionMessage: "Try passing the '--enable-experiment=#string' command line option."
analyzerCode: ParserErrorCode.EXPERIMENT_NOT_ENABLED_OFF_BY_DEFAULT
ExperimentDisabled:
problemMessage: "This requires the '#string' language feature to be enabled."
correctionMessage: "The feature is on by default but is currently disabled, maybe because the '--enable-experiment=no-#string' command line option is passed."
analyzerCode: ParserErrorCode.EXPERIMENT_NOT_ENABLED
ExperimentDisabledInvalidLanguageVersion:
problemMessage: "This requires the '#string' language feature, which requires language version of #string2 or higher."
analyzerCode: ParserErrorCode.EXPERIMENT_NOT_ENABLED
EmptyNamedParameterList:
problemMessage: "Named parameter lists cannot be empty."
correctionMessage: "Try adding a named parameter to the list."
analyzerCode: "MISSING_IDENTIFIER"
script: >
foo({}) {}
main() {
foo();
}
RecordLiteralOnePositionalFieldNoTrailingComma:
problemMessage: "A record literal with exactly one positional field requires a trailing comma."
correctionMessage: "Try adding a trailing comma."
analyzerCode: ParserErrorCode.RECORD_LITERAL_ONE_POSITIONAL_NO_TRAILING_COMMA
index: 127
hasPublishedDocs: true
documentation: |-
#### Description
The analyzer produces this diagnostic when a record literal with a single
positional field doesn't have a trailing comma after the field.
In some locations a record literal with a single positional field could
also be a parenthesized expression. A trailing comma is required to
disambiguate these two valid interpretations.
#### Example
The following code produces this diagnostic because the record literal has
one positional field but doesn't have a trailing comma:
```dart
var r = const (1[!)!];
```
#### Common fixes
Add a trailing comma:
```dart
var r = const (1,);
```
script: >
main() {
var record = const (1);
}
RecordLiteralZeroFieldsWithTrailingComma:
problemMessage: "A record literal without fields can't have a trailing comma."
correctionMessage: "Try removing the trailing comma."
analyzerCode: ParserErrorCode.EMPTY_RECORD_LITERAL_WITH_COMMA
index: 128
hasPublishedDocs: true
documentation: |-
#### Description
The analyzer produces this diagnostic when a record literal that has no
fields has a trailing comma. Empty record literals can't contain a comma.
#### Example
The following code produces this diagnostic because the empty record
literal has a trailing comma:
```dart
var r = ([!,!]);
```
#### Common fixes
If the record is intended to be empty, then remove the comma:
```dart
var r = ();
```
If the record is intended to have one or more fields, then add the
expressions used to compute the values of those fields:
```dart
var r = (3, 4);
```
script: >
main() {
var record = (,);
}
EmptyRecordTypeNamedFieldsList:
problemMessage: "The list of named fields in a record type can't be empty."
correctionMessage: "Try adding a named field to the list."
analyzerCode: ParserErrorCode.EMPTY_RECORD_TYPE_NAMED_FIELDS_LIST
index: 129
hasPublishedDocs: true
documentation: |-
#### Description
The analyzer produces this diagnostic when a record type has an empty list
of named fields.
#### Example
The following code produces this diagnostic because the record type has an
empty list of named fields:
```dart
void f((int, int, {[!}!]) r) {}
```
#### Common fixes
If the record is intended to have named fields, then add the types and
names of the fields:
```dart
void f((int, int, {int z}) r) {}
```
If the record isn't intended to have named fields, then remove the curly
braces:
```dart
void f((int, int) r) {}
```
script: >
main() {
(int, int, {/*missing*/}) record = (1, 2,);
}
RecordTypeZeroFieldsButTrailingComma:
problemMessage: "A record type without fields can't have a trailing comma."
correctionMessage: "Try removing the trailing comma."
analyzerCode: ParserErrorCode.EMPTY_RECORD_TYPE_WITH_COMMA
index: 130
hasPublishedDocs: true
documentation: |-
#### Description
The analyzer produces this diagnostic when a record type that has no
fields has a trailing comma. Empty record types can't contain a comma.
#### Example
The following code produces this diagnostic because the empty record type
has a trailing comma:
```dart
void f(([!,!]) r) {}
```
#### Common fixes
If the record type is intended to be empty, then remove the comma:
```dart
void f(() r) {}
```
If the record type is intended to have one or more fields, then add the
types of those fields:
```dart
void f((int, int) r) {}
```
script: >
main() {
(,) record = ();
}
RecordTypeOnePositionalFieldNoTrailingComma:
problemMessage: "A record type with exactly one positional field requires a trailing comma."
correctionMessage: "Try adding a trailing comma."
analyzerCode: ParserErrorCode.RECORD_TYPE_ONE_POSITIONAL_NO_TRAILING_COMMA
index: 131
hasPublishedDocs: true
documentation: |-
#### Description
The analyzer produces this diagnostic when a record type annotation with a
single positional field doesn't have a trailing comma after the field.
In some locations a record type with a single positional field could also
be a parenthesized expression. A trailing comma is required to
disambiguate these two valid interpretations.
#### Example
The following code produces this diagnostic because the record type has
one positional field, but doesn't have a trailing comma:
```dart
void f((int[!)!] r) {}
```
#### Common fixes
Add a trailing comma:
```dart
void f((int,) r) {}
```
script: >
main() {
(int /* missing trailing comma */) record = const (1, );
}
DuplicatedRecordTypeFieldName:
problemMessage: "Duplicated record type field name '#name'."
correctionMessage: "Try renaming or removing one of the named record type fields."
script: |
({int a, String a}) record = throw '';
DuplicatedRecordTypeFieldNameContext:
problemMessage: "This is the existing record type field named '#name'."
severity: CONTEXT
DuplicatedRecordLiteralFieldName:
problemMessage: "Duplicated record literal field name '#name'."
correctionMessage: "Try renaming or removing one of the named record literal fields."
script: |
dynamic field = (a: 0, a: 1);
DuplicatedRecordLiteralFieldNameContext:
problemMessage: "This is the existing record literal field named '#name'."
severity: CONTEXT
EmptyOptionalParameterList:
problemMessage: "Optional parameter lists cannot be empty."
correctionMessage: "Try adding an optional parameter to the list."
analyzerCode: "MISSING_IDENTIFIER"
script: >
foo([]) {}
main() {
foo();
}
ExpectedElseOrComma:
index: 46
problemMessage: "Expected 'else' or comma."
analyzerCode: ParserErrorCode.EXPECTED_ELSE_OR_COMMA
ExpectedBlock:
problemMessage: "Expected a block."
correctionMessage: "Try adding {}."
analyzerCode: EXPECTED_TOKEN
script: "try finally {}"
ExpectedBlockToSkip:
problemMessage: "Expected a function body or '=>'."
# TODO(ahe): In some scenarios, we can suggest removing the 'static' keyword.
correctionMessage: "Try adding {}."
analyzerCode: MISSING_FUNCTION_BODY
script: "main();"
ExpectedBody:
problemMessage: "Expected a function body or '=>'."
# TODO(ahe): In some scenarios, we can suggest removing the 'static' keyword.
correctionMessage: "Try adding {}."
analyzerCode: MISSING_FUNCTION_BODY
script: "main();"
ExpectedStatement:
index: 29
problemMessage: "Expected a statement."
analyzerCode: ParserErrorCode.MISSING_STATEMENT
statement: "void;"
ExpectedButGot:
# Also see ExpectedAfterButGot and ExpectedInstead
problemMessage: "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
problemMessage: "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
problemMessage: "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:
- "class B {} mixin A extends B { }"
MultipleLibraryDirectives:
index: 27
problemMessage: "Only one library directive may be declared in a file."
correctionMessage: "Try removing all but one of the library directives."
analyzerCode: ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES
MultipleExtends:
index: 28
problemMessage: "Each class definition can have at most one extends clause."
correctionMessage: "Try choosing one superclass and define your class to implement (or mix in) the others."
analyzerCode: ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES
script:
- "class B{} class C{} class A extends B extends C {}"
- "class B{} class C{} class A extends B, C {}"
MultipleWith:
index: 24
problemMessage: "Each class definition can have at most one with clause."
correctionMessage: "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
problemMessage: "The extends clause must be before the with clause."
correctionMessage: "Try moving the extends clause before the with clause."
analyzerCode: ParserErrorCode.WITH_BEFORE_EXTENDS
script: "mixin B {} class C {} class A with B extends C {}"
ImplementsBeforeExtends:
index: 44
problemMessage: "The extends clause must be before the implements clause."
correctionMessage: "Try moving the extends clause before the implements clause."
analyzerCode: ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS
script: "class A implements B extends C {}"
ImplementsBeforeOn:
index: 43
problemMessage: "The on clause must be before the implements clause."
correctionMessage: "Try moving the on clause before the implements clause."
analyzerCode: ParserErrorCode.IMPLEMENTS_BEFORE_ON
script: "mixin A implements B on C {}"
ImplementsBeforeWith:
index: 42
problemMessage: "The with clause must be before the implements clause."
correctionMessage: "Try moving the with clause before the implements clause."
analyzerCode: ParserErrorCode.IMPLEMENTS_BEFORE_WITH
script: "class A extends B implements C with D {}"
ImplementsRepeated:
problemMessage: "'#name' can only be implemented once."
analyzerCode: IMPLEMENTS_REPEATED
correctionMessage: "Try removing #count of the occurrences."
script:
- >-
abstract class I {}
abstract class J {}
class K implements I, J, I {}
ImplementsSuperClass:
problemMessage: "'#name' can't be used in both 'extends' and 'implements' clauses."
analyzerCode: IMPLEMENTS_SUPER_CLASS
correctionMessage: "Try removing one of the occurrences."
script:
- >-
abstract class A {}
class C extends A implements A {}
MultipleImplements:
problemMessage: "Each class definition can have at most one implements clause."
correctionMessage: "Try combining all of the implements clauses into a single clause."
analyzerCode: MULTIPLE_IMPLEMENTS_CLAUSES
script: "class A implements B implements C, D {}"
MultipleClauses:
problemMessage: "Each '#string' definition can have at most one '#string2' clause."
correctionMessage: "Try combining all of the '#string2' clauses into a single clause."
analyzerCode: ParserErrorCode.MULTIPLE_CLAUSES
index: 121
script:
- "mixin B {} enum A implements B implements C, D { v; }"
- "mixin B {} enum A with B with C, D { v; }"
OutOfOrderClauses:
problemMessage: "The '#string' clause must come before the '#string2' clause."
correctionMessage: "Try moving the '#string' clause before the '#string2' clause."
analyzerCode: ParserErrorCode.OUT_OF_ORDER_CLAUSES
index: 122
script: "class B {} class D {} enum A implements B with D { v; }"
MultipleOnClauses:
index: 26
problemMessage: "Each mixin definition can have at most one on clause."
correctionMessage: "Try combining all of the on clauses into a single clause."
analyzerCode: ParserErrorCode.MULTIPLE_ON_CLAUSES
script: "mixin A on B on C, D {}"
MixinWithClause:
index: 154
problemMessage: "A mixin can't have a with clause."
analyzerCode: ParserErrorCode.MIXIN_WITH_CLAUSE
script: "mixin M {} mixin N with M {}"
ExtendsFutureOr:
problemMessage: "The type 'FutureOr' can't be used in an 'extends' clause."
ImplementsFutureOr:
problemMessage: "The type 'FutureOr' can't be used in an 'implements' clause."
ExtendsNever:
problemMessage: "The type 'Never' can't be used in an 'extends' clause."
ImplementsNever:
problemMessage: "The type 'Never' can't be used in an 'implements' clause."
ExtendsVoid:
problemMessage: "The type 'void' can't be used in an 'extends' clause."
ImplementsVoid:
problemMessage: "The type 'void' can't be used in an 'implements' clause."
ExpectedClassBody:
index: 8
problemMessage: "A class declaration must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_CLASS_BODY
sharedName: EXPECTED_BODY
script: |
class Class
ExpectedMixinBody:
index: 166
problemMessage: "A mixin declaration must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_MIXIN_BODY
sharedName: EXPECTED_BODY
script: |
mixin Mixin
ExpectedExtensionBody:
index: 173
problemMessage: "An extension declaration must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_EXTENSION_BODY
sharedName: EXPECTED_BODY
script: |
extension Extension on int
ExpectedExtensionTypeBody:
index: 167
problemMessage: "An extension type declaration must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_EXTENSION_TYPE_BODY
sharedName: EXPECTED_BODY
script: |
extension type ExtensionType(int i)
ExpectedTryStatementBody:
index: 168
problemMessage: "A try statement must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_TRY_STATEMENT_BODY
sharedName: EXPECTED_BODY
script: |
method() {
try finally {}
}
ExpectedCatchClauseBody:
index: 169
problemMessage: "A catch clause must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_CATCH_CLAUSE_BODY
sharedName: EXPECTED_BODY
script: |
method() {
try {} catch (_);
}
ExpectedFinallyClauseBody:
index: 170
problemMessage: "A finally clause must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_FINALLY_CLAUSE_BODY
sharedName: EXPECTED_BODY
script: |
method() {
try {} finally;
}
ExpectedSwitchExpressionBody:
index: 171
problemMessage: "A switch expression must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_SWITCH_EXPRESSION_BODY
sharedName: EXPECTED_BODY
script: |
method(Never n) => switch (n);
ExpectedSwitchStatementBody:
index: 172
problemMessage: "A switch statement must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_SWITCH_STATEMENT_BODY
sharedName: EXPECTED_BODY
script: |
method(Never n) {
switch (n);
}
ExpectedDeclaration:
problemMessage: "Expected a declaration, but got '#lexeme'."
analyzerCode: EXPECTED_EXECUTABLE
ExpectedClassMember:
problemMessage: "Expected a class member, but got '#lexeme'."
analyzerCode: EXPECTED_CLASS_MEMBER
ExpectedFunctionBody:
problemMessage: "Expected a function body, but got '#lexeme'."
analyzerCode: MISSING_FUNCTION_BODY
ExpectedHexDigit:
problemMessage: "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:
problemMessage: "Expected an identifier, but got '#lexeme'."
correctionMessage: "Try inserting an identifier before '#lexeme'."
analyzerCode: MISSING_IDENTIFIER
script: "var = 42;"
ExpectedIdentifierButGotKeyword:
problemMessage: "'#lexeme' can't be used as an identifier because it's a keyword."
correctionMessage: "Try renaming this to be an identifier that isn't a keyword."
index: 113
analyzerCode: ParserErrorCode.EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD
script: "var default = 42;"
EqualityCannotBeEqualityOperand:
index: 1
problemMessage: "A comparison expression can't be an operand of another comparison expression."
correctionMessage: "Try putting parentheses around one of the comparisons."
analyzerCode: ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND
script:
- "main() { var b = a < b < c; }"
- "main() { var b = a == b != c; }"
ExpectedOpenParens:
problemMessage: "Expected '('."
ExpectedString:
problemMessage: "Expected a String, but got '#lexeme'."
analyzerCode: EXPECTED_STRING_LITERAL
ExpectedToken:
problemMessage: "Expected to find '#string'."
analyzerCode: EXPECTED_TOKEN
ExpectedType:
problemMessage: "Expected a type, but got '#lexeme'."
analyzerCode: EXPECTED_TYPE_NAME
VarAsTypeName:
index: 61
problemMessage: "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
problemMessage: "Missing expression after 'throw'."
correctionMessage: "Add an expression after 'throw' or use 'rethrow' to throw a caught exception"
analyzerCode: ParserErrorCode.MISSING_EXPRESSION_IN_THROW
statement:
- "throw;"
MissingConstFinalVarOrType:
index: 33
problemMessage: "Variables must be declared using the keywords 'const', 'final', 'var' or a type name."
correctionMessage: "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:
index: 119
problemMessage: "Function-typed parameters can't specify 'const', 'final' or 'var' in place of a return type."
correctionMessage: "Try replacing the keyword with a return type."
analyzerCode: ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR
script:
- "void f(const x()) {}"
- "void f(final x()) {}"
- "void f(var x()) {}"
AbstractClassMember:
index: 51
problemMessage: "Members of classes can't be declared to be 'abstract'."
correctionMessage: "Try removing the 'abstract' keyword. You can add the 'abstract' keyword before the class declaration."
analyzerCode: ParserErrorCode.ABSTRACT_CLASS_MEMBER
configuration: nnbd-weak
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);}
AbstractExternalField:
index: 110
problemMessage: "Fields can't be declared both 'abstract' and 'external'."
analyzerCode: ParserErrorCode.ABSTRACT_EXTERNAL_FIELD
correctionMessage: "Try removing the 'abstract' or 'external' keyword."
script:
- "abstract class C {abstract external var f;}"
- "abstract class C {external abstract var f;}"
AbstractStaticField:
index: 107
problemMessage: "Static fields can't be declared 'abstract'."
analyzerCode: ParserErrorCode.ABSTRACT_STATIC_FIELD
correctionMessage: "Try removing the 'abstract' or 'static' keyword."
script:
- "abstract class C {abstract static var f;}"
AbstractExtensionField:
problemMessage: "Extension fields can't be declared 'abstract'."