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

Side by Side Diff: pkg/compiler/lib/src/diagnostics/dart2js_messages.dart

Issue 1503053004: Move messages out of dart2js. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
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.
4
5 // The messages in this file should meet the following guide lines:
6 //
7 // 1. The message should be a complete sentence starting with an uppercase
8 // letter, and ending with a period.
9 //
10 // 2. Reserved words and embedded identifiers should be in single quotes, so
11 // prefer double quotes for the complete message. For example, "The
12 // class '#{className}' can't use 'super'." Notice that the word 'class' in the
13 // preceding message is not quoted as it refers to the concept 'class', not the
14 // reserved word. On the other hand, 'super' refers to the reserved word. Do
15 // not quote 'null' and numeric literals.
16 //
17 // 3. Do not try to compose messages, as it can make translating them hard.
18 //
19 // 4. Try to keep the error messages short, but informative.
20 //
21 // 5. Use simple words and terminology, assume the reader of the message
22 // doesn't have an advanced degree in math, and that English is not the
23 // reader's native language. Do not assume any formal computer science
24 // training. For example, do not use Latin abbreviations (prefer "that is" over
25 // "i.e.", and "for example" over "e.g."). Also avoid phrases such as "if and
26 // only if" and "iff", that level of precision is unnecessary.
27 //
28 // 6. Prefer contractions when they are in common use, for example, prefer
29 // "can't" over "cannot". Using "cannot", "must not", "shall not", etc. is
30 // off-putting to people new to programming.
31 //
32 // 7. Use common terminology, preferably from the Dart Language
33 // Specification. This increases the user's chance of finding a good
34 // explanation on the web.
35 //
36 // 8. Do not try to be cute or funny. It is extremely frustrating to work on a
37 // product that crashes with a "tongue-in-cheek" message, especially if you did
38 // not want to use this product to begin with.
39 //
40 // 9. Do not lie, that is, do not write error messages containing phrases like
41 // "can't happen". If the user ever saw this message, it would be a
42 // lie. Prefer messages like: "Internal error: This function should not be
43 // called when 'x' is null.".
44 //
45 // 10. Prefer to not use imperative tone. That is, the message should not sound
46 // accusing or like it is ordering the user around. The computer should
47 // describe the problem, not criticize for violating the specification.
48 //
49 // Other things to keep in mind:
50 //
51 // An INFO message should always be preceded by a non-INFO message, and the
52 // INFO messages are additional details about the preceding non-INFO
53 // message. For example, consider duplicated elements. First report a WARNING
54 // or ERROR about the duplicated element, and then report an INFO about the
55 // location of the existing element.
56 //
57 // Generally, we want to provide messages that consists of three sentences:
58 // 1. what is wrong, 2. why is it wrong, 3. how do I fix it. However, we
59 // combine the first two in [template] and the last in [howToFix].
60
61 /// Padding used before and between import chains in the message for
62 /// [MessageKind.IMPORT_EXPERIMENTAL_MIRRORS].
63 const String IMPORT_EXPERIMENTAL_MIRRORS_PADDING = '\n* ';
64
65 /// Padding used before and between import chains in the message for
66 /// [MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND].
67 const String MIRRORS_NOT_SUPPORTED_BY_BACKEND_PADDING = '\n ';
68
69 /// Padding used before and between import chains in the message for
70 /// [MessageKind.DISALLOWED_LIBRARY_IMPORT].
71 const String DISALLOWED_LIBRARY_IMPORT_PADDING = '\n ';
72
73 const DONT_KNOW_HOW_TO_FIX = "Computer says no!";
74
75 final Map<String, Map> MESSAGES = {
76 /// Do not use this. It is here for legacy and debugging. It violates item
77 /// 4 of the guide lines for error messages in the beginning of the file.
78 'GENERIC': {'id': 'SOWPSL', 'template': "#{text}",},
79
80 'NOT_ASSIGNABLE': {
81 'id': 'VYNMAP',
82 'template': "'#{fromType}' is not assignable to '#{toType}'.",
83 },
84
85 'FORIN_NOT_ASSIGNABLE': {
86 'id': 'XQSRXO',
87 'template': "The element type '#{currentType}' of '#{expressionType}' "
88 "is not assignable to '#{elementType}'.",
89 },
90
91 'VOID_EXPRESSION': {
92 'id': 'QHEVSC',
93 'template': "Expression does not yield a value.",
94 },
95
96 'VOID_VARIABLE': {
97 'id': 'RFEURK',
98 'template': "Variable cannot be of type void.",
99 },
100
101 'RETURN_VALUE_IN_VOID': {
102 'id': 'FUNYDS',
103 'template': "Cannot return value from void function.",
104 },
105
106 'RETURN_NOTHING': {
107 'id': 'HPPODJ',
108 'template': "Value of type '#{returnType}' expected.",
109 },
110
111 'MISSING_ARGUMENT': {
112 'id': 'LHMCIK',
113 'template': "Missing argument of type '#{argumentType}'.",
114 },
115
116 'ADDITIONAL_ARGUMENT': {'id': 'GMITMA', 'template': "Additional argument.",},
117
118 'NAMED_ARGUMENT_NOT_FOUND': {
119 'id': 'UCEARQ',
120 'template': "No named argument '#{argumentName}' found on method.",
121 },
122
123 'MEMBER_NOT_FOUND': {
124 'id': 'MMQODC',
125 'template': "No member named '#{memberName}' in class '#{className}'.",
126 },
127
128 'AWAIT_MEMBER_NOT_FOUND': {
129 'id': 'XIDLIP',
130 'template': "No member named 'await' in class '#{className}'.",
131 'howToFix': "Did you mean to add the 'async' marker "
132 "to '#{functionName}'?",
133 'examples': [
134 """
135 class A {
136 m() => await -3;
137 }
138 main() => new A().m();
139 """
140 ],
141 },
142
143 'AWAIT_MEMBER_NOT_FOUND_IN_CLOSURE': {
144 'id': 'HBIYGN',
145 'template': "No member named 'await' in class '#{className}'.",
146 'howToFix': "Did you mean to add the 'async' marker "
147 "to the enclosing function?",
148 'examples': [
149 """
150 class A {
151 m() => () => await -3;
152 }
153 main() => new A().m();
154 """
155 ],
156 },
157
158 'METHOD_NOT_FOUND': {
159 'id': 'QYYHBU',
160 'template': "No method named '#{memberName}' in class '#{className}'.",
161 },
162
163 'OPERATOR_NOT_FOUND': {
164 'id': 'SXGOYS',
165 'template': "No operator '#{memberName}' in class '#{className}'.",
166 },
167
168 'SETTER_NOT_FOUND': {
169 'id': 'ADFRVF',
170 'template': "No setter named '#{memberName}' in class '#{className}'.",
171 },
172
173 'SETTER_NOT_FOUND_IN_SUPER': {
174 'id': 'OCVRNJ',
175 'template': "No setter named '#{name}' in superclass of '#{className}'.",
176 },
177
178 'GETTER_NOT_FOUND': {
179 'id': 'PBNXAC',
180 'template': "No getter named '#{memberName}' in class '#{className}'.",
181 },
182
183 'NOT_CALLABLE': {
184 'id': 'SEMKJO',
185 'template': "'#{elementName}' is not callable.",
186 },
187
188 'MEMBER_NOT_STATIC': {
189 'id': 'QIOISX',
190 'template': "'#{className}.#{memberName}' is not static.",
191 },
192
193 'NO_INSTANCE_AVAILABLE': {
194 'id': 'FQPYLR',
195 'template': "'#{name}' is only available in instance methods.",
196 },
197
198 'NO_THIS_AVAILABLE': {
199 'id': 'LXPXKG',
200 'template': "'this' is only available in instance methods.",
201 },
202
203 'PRIVATE_ACCESS': {
204 'id': 'DIMHCR',
205 'template': "'#{name}' is declared private within library "
206 "'#{libraryName}'.",
207 },
208
209 'THIS_IS_THE_DECLARATION': {
210 'id': 'YIJWTO',
211 'template': "This is the declaration of '#{name}'.",
212 },
213
214 'THIS_IS_THE_METHOD': {
215 'id': 'PYXWLF',
216 'template': "This is the method declaration.",
217 },
218
219 'CANNOT_RESOLVE': {'id': 'SPVJYO', 'template': "Cannot resolve '#{name}'.",},
220
221 'CANNOT_RESOLVE_AWAIT': {
222 'id': 'YQYLRS',
223 'template': "Cannot resolve '#{name}'.",
224 'howToFix': "Did you mean to add the 'async' marker "
225 "to '#{functionName}'?",
226 'examples': ["main() => await -3;", "foo() => await -3; main() => foo();"],
227 },
228
229 'CANNOT_RESOLVE_AWAIT_IN_CLOSURE': {
230 'id': 'SIXRAA',
231 'template': "Cannot resolve '#{name}'.",
232 'howToFix': "Did you mean to add the 'async' marker "
233 "to the enclosing function?",
234 'examples': ["main() { (() => await -3)(); }",],
235 },
236
237 'CANNOT_RESOLVE_IN_INITIALIZER': {
238 'id': 'VVEQFD',
239 'template':
240 "Cannot resolve '#{name}'. It would be implicitly looked up on this "
241 "instance, but instances are not available in initializers.",
242 'howToFix': "Try correcting the unresolved reference or move the "
243 "initialization to a constructor body.",
244 'examples': [
245 """
246 class A {
247 var test = unresolvedName;
248 }
249 main() => new A();
250 """
251 ],
252 },
253
254 'CANNOT_RESOLVE_CONSTRUCTOR': {
255 'id': 'QRPATN',
256 'template': "Cannot resolve constructor '#{constructorName}'.",
257 },
258
259 'CANNOT_RESOLVE_CONSTRUCTOR_FOR_IMPLICIT': {
260 'id': 'IFKCHF',
261 'template': "cannot resolve constructor '#{constructorName}' "
262 "for implicit super call.",
263 'howToFix': "Try explicitly invoking a constructor of the super class",
264 'examples': [
265 """
266 class A {
267 A.foo() {}
268 }
269 class B extends A {
270 B();
271 }
272 main() => new B();
273 """
274 ],
275 },
276
277 'INVALID_UNNAMED_CONSTRUCTOR_NAME': {
278 'id': 'VPJLVI',
279 'template': "Unnamed constructor name must be '#{name}'.",
280 },
281
282 'INVALID_CONSTRUCTOR_NAME': {
283 'id': 'LMDCAS',
284 'template': "Constructor name must start with '#{name}'.",
285 },
286
287 'CANNOT_RESOLVE_TYPE': {
288 'id': 'PQIAPG',
289 'template': "Cannot resolve type '#{typeName}'.",
290 },
291
292 'DUPLICATE_DEFINITION': {
293 'id': 'LVTYNW',
294 'template': "Duplicate definition of '#{name}'.",
295 'howToFix': "Try to rename or remove this definition.",
296 'examples': [
297 """
298 class C {
299 void f() {}
300 int get f => 1;
301 }
302
303 main() {
304 new C();
305 }
306
307 """
308 ],
309 },
310
311 'EXISTING_DEFINITION': {
312 'id': 'DAUYKK',
313 'template': "Existing definition of '#{name}'.",
314 },
315
316 'DUPLICATE_IMPORT': {
317 'id': 'KYJFJN',
318 'template': "Duplicate import of '#{name}'.",
319 },
320
321 'HIDDEN_IMPORT': {
322 'id': 'ACRDPR',
323 'template': "'#{name}' from library '#{hiddenUri}' is hidden by '#{name}' "
324 "from library '#{hidingUri}'.",
325 'howToFix': "Try adding 'hide #{name}' to the import of '#{hiddenUri}'.",
326 'examples': [
327 {
328 'main.dart': """
329 import 'dart:async'; // This imports a class Future.
330 import 'future.dart';
331
332 void main() => new Future();""",
333 'future.dart': """
334 library future;
335
336 class Future {}"""
337 },
338 {
339 'main.dart': """
340 import 'future.dart';
341 import 'dart:async'; // This imports a class Future.
342
343 void main() => new Future();""",
344 'future.dart': """
345 library future;
346
347 class Future {}"""
348 },
349 {
350 'main.dart': """
351 import 'export.dart';
352 import 'dart:async'; // This imports a class Future.
353
354 void main() => new Future();""",
355 'future.dart': """
356 library future;
357
358 class Future {}""",
359 'export.dart': """
360 library export;
361
362 export 'future.dart';"""
363 },
364 {
365 'main.dart': """
366 import 'future.dart' as prefix;
367 import 'dart:async' as prefix; // This imports a class Future.
368
369 void main() => new prefix.Future();""",
370 'future.dart': """
371 library future;
372
373 class Future {}"""
374 }
375 ],
376 },
377
378 'HIDDEN_IMPLICIT_IMPORT': {
379 'id': 'WDNFSI',
380 'template': "'#{name}' from library '#{hiddenUri}' is hidden by '#{name}' "
381 "from library '#{hidingUri}'.",
382 'howToFix': "Try adding an explicit "
383 "'import \"#{hiddenUri}\" hide #{name}'.",
384 'examples': [
385 {
386 'main.dart': """
387 // This hides the implicit import of class Type from dart:core.
388 import 'type.dart';
389
390 void main() => new Type();""",
391 'type.dart': """
392 library type;
393
394 class Type {}"""
395 },
396 {
397 'conflictsWithDart.dart': """
398 library conflictsWithDart;
399
400 class Duration {
401 static var x = 100;
402 }
403 """,
404 'conflictsWithDartAsWell.dart': """
405 library conflictsWithDartAsWell;
406
407 class Duration {
408 static var x = 100;
409 }
410 """,
411 'main.dart': r"""
412 library testDartConflicts;
413
414 import 'conflictsWithDart.dart';
415 import 'conflictsWithDartAsWell.dart';
416
417 main() {
418 print("Hail Caesar ${Duration.x}");
419 }
420 """
421 }
422 ],
423 },
424
425 'DUPLICATE_EXPORT': {
426 'id': 'XGNOCL',
427 'template': "Duplicate export of '#{name}'.",
428 'howToFix': "Try adding 'hide #{name}' to one of the exports.",
429 'examples': [
430 {
431 'main.dart': """
432 export 'decl1.dart';
433 export 'decl2.dart';
434
435 main() {}""",
436 'decl1.dart': "class Class {}",
437 'decl2.dart': "class Class {}"
438 }
439 ],
440 },
441
442 'DUPLICATE_EXPORT_CONT': {
443 'id': 'BDROED',
444 'template': "This is another export of '#{name}'.",
445 },
446
447 'DUPLICATE_EXPORT_DECL': {
448 'id': 'GFFLMA',
449 'template':
450 "The exported '#{name}' from export #{uriString} is defined here.",
451 },
452
453 'EMPTY_HIDE': {
454 'id': 'ODFAOC',
455 'template': "Library '#{uri}' doesn't export a '#{name}' declaration.",
456 'howToFix': "Try removing '#{name}' the 'hide' clause.",
457 'examples': [
458 {
459 'main.dart': """
460 import 'dart:core' hide Foo;
461
462 main() {}"""
463 },
464 {
465 'main.dart': """
466 export 'dart:core' hide Foo;
467
468 main() {}"""
469 },
470 ],
471 },
472
473 'EMPTY_SHOW': {
474 'id': 'EXONIK',
475 'template': "Library '#{uri}' doesn't export a '#{name}' declaration.",
476 'howToFix': "Try removing '#{name}' from the 'show' clause.",
477 'examples': [
478 {
479 'main.dart': """
480 import 'dart:core' show Foo;
481
482 main() {}"""
483 },
484 {
485 'main.dart': """
486 export 'dart:core' show Foo;
487
488 main() {}"""
489 },
490 ],
491 },
492
493 'NOT_A_TYPE': {'id': 'CTTAXD', 'template': "'#{node}' is not a type.",},
494
495 'NOT_A_PREFIX': {'id': 'LKEUMI', 'template': "'#{node}' is not a prefix.",},
496
497 'PREFIX_AS_EXPRESSION': {
498 'id': 'CYIMBJ',
499 'template': "Library prefix '#{prefix}' is not a valid expression.",
500 },
501
502 'CANNOT_FIND_CONSTRUCTOR': {
503 'id': 'DROVNH',
504 'template': "Cannot find constructor '#{constructorName}' in class "
505 "'#{className}'.",
506 },
507
508 'CANNOT_FIND_UNNAMED_CONSTRUCTOR': {
509 'id': 'GDCTGB',
510 'template': "Cannot find unnamed constructor in class "
511 "'#{className}'.",
512 },
513
514 'CYCLIC_CLASS_HIERARCHY': {
515 'id': 'HKFYOA',
516 'template': "'#{className}' creates a cycle in the class hierarchy.",
517 },
518
519 'CYCLIC_REDIRECTING_FACTORY': {
520 'id': 'QGETJC',
521 'template': "Redirecting factory leads to a cyclic redirection.",
522 },
523
524 'INVALID_RECEIVER_IN_INITIALIZER': {
525 'id': 'SYUTHA',
526 'template': "Field initializer expected.",
527 },
528
529 'NO_SUPER_IN_STATIC': {
530 'id': 'HSCESG',
531 'template': "'super' is only available in instance methods.",
532 },
533
534 'DUPLICATE_INITIALIZER': {
535 'id': 'GKVFEP',
536 'template': "Field '#{fieldName}' is initialized more than once.",
537 },
538
539 'ALREADY_INITIALIZED': {
540 'id': 'NCRMVD',
541 'template': "'#{fieldName}' was already initialized here.",
542 },
543
544 'INIT_STATIC_FIELD': {
545 'id': 'DBSRHA',
546 'template': "Cannot initialize static field '#{fieldName}'.",
547 },
548
549 'NOT_A_FIELD': {
550 'id': 'FYEPLC',
551 'template': "'#{fieldName}' is not a field.",
552 },
553
554 'CONSTRUCTOR_CALL_EXPECTED': {
555 'id': 'GEJCDX',
556 'template': "only call to 'this' or 'super' constructor allowed.",
557 },
558
559 'INVALID_FOR_IN': {
560 'id': 'AUQJBG',
561 'template': "Invalid for-in variable declaration.",
562 },
563
564 'INVALID_INITIALIZER': {'id': 'JKUKSA', 'template': "Invalid initializer.",},
565
566 'FUNCTION_WITH_INITIALIZER': {
567 'id': 'BNRDDK',
568 'template': "Only constructors can have initializers.",
569 },
570
571 'REDIRECTING_CONSTRUCTOR_CYCLE': {
572 'id': 'CQTMEP',
573 'template': "Cyclic constructor redirection.",
574 },
575
576 'REDIRECTING_CONSTRUCTOR_HAS_BODY': {
577 'id': 'WXJQNE',
578 'template': "Redirecting constructor can't have a body.",
579 },
580
581 'CONST_CONSTRUCTOR_HAS_BODY': {
582 'id': 'GNEFQG',
583 'template': "Const constructor or factory can't have a body.",
584 'howToFix': "Remove the 'const' keyword or the body",
585 'examples': [
586 """
587 class C {
588 const C() {}
589 }
590
591 main() => new C();"""
592 ],
593 },
594
595 'REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER': {
596 'id': 'NUIDSF',
597 'template': "Redirecting constructor cannot have other initializers.",
598 },
599
600 'SUPER_INITIALIZER_IN_OBJECT': {
601 'id': 'DXYGND',
602 'template': "'Object' cannot have a super initializer.",
603 },
604
605 'DUPLICATE_SUPER_INITIALIZER': {
606 'id': 'FFKOWP',
607 'template': "Cannot have more than one super initializer.",
608 },
609
610 'SUPER_CALL_TO_FACTORY': {
611 'id': 'YTOWGV',
612 'template': "The target of the superinitializer must be a generative "
613 "constructor.",
614 'howToFix': "Try calling another constructor on the superclass.",
615 'examples': [
616 """
617 class Super {
618 factory Super() => null;
619 }
620 class Class extends Super {}
621 main() => new Class();
622 """,
623 """
624 class Super {
625 factory Super() => null;
626 }
627 class Class extends Super {
628 Class();
629 }
630 main() => new Class();
631 """,
632 """
633 class Super {
634 factory Super() => null;
635 }
636 class Class extends Super {
637 Class() : super();
638 }
639 main() => new Class();
640 """,
641 """
642 class Super {
643 factory Super.foo() => null;
644 }
645 class Class extends Super {
646 Class() : super.foo();
647 }
648 main() => new Class();
649 """
650 ],
651 },
652
653 'THIS_CALL_TO_FACTORY': {
654 'id': 'JLATDB',
655 'template': "The target of the redirection clause must be a generative "
656 "constructor",
657 'howToFix': "Try redirecting to another constructor.",
658 'examples': [
659 """
660 class Class {
661 factory Class() => null;
662 Class.foo() : this();
663 }
664 main() => new Class.foo();
665 """,
666 """
667 class Class {
668 factory Class.foo() => null;
669 Class() : this.foo();
670 }
671 main() => new Class();
672 """
673 ],
674 },
675
676 'INVALID_CONSTRUCTOR_ARGUMENTS': {
677 'id': 'WVPLKL',
678 'template': "Arguments do not match the expected parameters of constructor "
679 "'#{constructorName}'.",
680 },
681
682 'NO_MATCHING_CONSTRUCTOR': {
683 'id': 'OJQQLE',
684 'template':
685 "'super' call arguments and constructor parameters do not match.",
686 },
687
688 'NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT': {
689 'id': 'WHCVID',
690 'template': "Implicit 'super' call arguments and constructor parameters "
691 "do not match.",
692 },
693
694 'CONST_CALLS_NON_CONST': {
695 'id': 'CQFHXC',
696 'template': "'const' constructor cannot call a non-const constructor.",
697 },
698
699 'CONST_CALLS_NON_CONST_FOR_IMPLICIT': {
700 'id': 'SFCEXS',
701 'template': "'const' constructor cannot call a non-const constructor. "
702 "This constructor has an implicit call to a "
703 "super non-const constructor.",
704 'howToFix': "Try making the super constructor const.",
705 'examples': [
706 """
707 class C {
708 C(); // missing const
709 }
710 class D extends C {
711 final d;
712 const D(this.d);
713 }
714 main() => new D(0);"""
715 ],
716 },
717
718 'CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS': {
719 'id': 'XBHUDL',
720 'template': "Can't declare constructor 'const' on class #{className} "
721 "because the class contains non-final instance fields.",
722 'howToFix': "Try making all fields final.",
723 'examples': [
724 """
725 class C {
726 // 'a' must be declared final to allow for the const constructor.
727 var a;
728 const C(this.a);
729 }
730
731 main() => new C(0);"""
732 ],
733 },
734
735 'CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD': {
736 'id': 'YYAHVD',
737 'template': "This non-final field prevents using const constructors.",
738 },
739
740 'CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR': {
741 'id': 'FROWJB',
742 'template': "This const constructor is not allowed due to "
743 "non-final fields.",
744 },
745
746 'INITIALIZING_FORMAL_NOT_ALLOWED': {
747 'id': 'YIPXYP',
748 'template': "Initializing formal parameter only allowed in generative "
749 "constructor.",
750 },
751
752 'INVALID_PARAMETER': {
753 'id': 'OWWLIX',
754 'template': "Cannot resolve parameter.",
755 },
756
757 'NOT_INSTANCE_FIELD': {
758 'id': 'VSPKMU',
759 'template': "'#{fieldName}' is not an instance field.",
760 },
761
762 'THIS_PROPERTY': {'id': 'MWFIGH', 'template': "Expected an identifier.",},
763
764 'NO_CATCH_NOR_FINALLY': {
765 'id': 'OPJXPP',
766 'template': "Expected 'catch' or 'finally'.",
767 },
768
769 'EMPTY_CATCH_DECLARATION': {
770 'id': 'UNHCPY',
771 'template': "Expected an identifier in catch declaration.",
772 },
773
774 'EXTRA_CATCH_DECLARATION': {
775 'id': 'YGGRAK',
776 'template': "Extra parameter in catch declaration.",
777 },
778
779 'PARAMETER_WITH_TYPE_IN_CATCH': {
780 'id': 'EXQVDU',
781 'template': "Cannot use type annotations in catch.",
782 },
783
784 'PARAMETER_WITH_MODIFIER_IN_CATCH': {
785 'id': 'BQLKRF',
786 'template': "Cannot use modifiers in catch.",
787 },
788
789 'OPTIONAL_PARAMETER_IN_CATCH': {
790 'id': 'DAICPP',
791 'template': "Cannot use optional parameters in catch.",
792 },
793
794 'THROW_WITHOUT_EXPRESSION': {
795 'id': 'YHACYV',
796 'template': "Cannot use re-throw outside of catch block "
797 "(expression expected after 'throw').",
798 },
799
800 'UNBOUND_LABEL': {
801 'id': 'GLDXHY',
802 'template': "Cannot resolve label '#{labelName}'.",
803 },
804
805 'NO_BREAK_TARGET': {
806 'id': 'VBXXBE',
807 'template': "'break' statement not inside switch or loop.",
808 },
809
810 'NO_CONTINUE_TARGET': {
811 'id': 'JTTHHM',
812 'template': "'continue' statement not inside loop.",
813 },
814
815 'EXISTING_LABEL': {
816 'id': 'AHCSXF',
817 'template': "Original declaration of duplicate label '#{labelName}'.",
818 },
819
820 'DUPLICATE_LABEL': {
821 'id': 'HPULLI',
822 'template': "Duplicate declaration of label '#{labelName}'.",
823 },
824
825 'UNUSED_LABEL': {'id': 'KFREJO', 'template': "Unused label '#{labelName}'.",},
826
827 'INVALID_CONTINUE': {
828 'id': 'DSKTPX',
829 'template': "Target of continue is not a loop or switch case.",
830 },
831
832 'INVALID_BREAK': {
833 'id': 'MFCCWX',
834 'template': "Target of break is not a statement.",
835 },
836
837 'DUPLICATE_TYPE_VARIABLE_NAME': {
838 'id': 'BAYCCM',
839 'template': "Type variable '#{typeVariableName}' already declared.",
840 },
841
842 'TYPE_VARIABLE_WITHIN_STATIC_MEMBER': {
843 'id': 'XQLXRL',
844 'template': "Cannot refer to type variable '#{typeVariableName}' "
845 "within a static member.",
846 },
847
848 'TYPE_VARIABLE_IN_CONSTANT': {
849 'id': 'ANDEVG',
850 'template': "Constant expressions can't refer to type variables.",
851 'howToFix': "Try removing the type variable or replacing it with a "
852 "concrete type.",
853 'examples': [
854 """
855 class C<T> {
856 const C();
857
858 m(T t) => const C<T>();
859 }
860
861 void main() => new C().m(null);
862 """
863 ],
864 },
865
866 'INVALID_TYPE_VARIABLE_BOUND': {
867 'id': 'WQAEDK',
868 'template': "'#{typeArgument}' is not a subtype of bound '#{bound}' for "
869 "type variable '#{typeVariable}' of type '#{thisType}'.",
870 'howToFix': "Try to change or remove the type argument.",
871 'examples': [
872 """
873 class C<T extends num> {}
874
875 // 'String' is not a valid instantiation of T with bound num.'.
876 main() => new C<String>();
877 """
878 ],
879 },
880
881 'INVALID_USE_OF_SUPER': {
882 'id': 'JKYYSN',
883 'template': "'super' not allowed here.",
884 },
885
886 'INVALID_CASE_DEFAULT': {
887 'id': 'ABSPBM',
888 'template': "'default' only allowed on last case of a switch.",
889 },
890
891 'SWITCH_CASE_TYPES_NOT_EQUAL': {
892 'id': 'UFQPBC',
893 'template': "'case' expressions do not all have type '#{type}'.",
894 },
895
896 'SWITCH_CASE_TYPES_NOT_EQUAL_CASE': {
897 'id': 'RDMVAC',
898 'template': "'case' expression of type '#{type}'.",
899 },
900
901 'SWITCH_CASE_FORBIDDEN': {
902 'id': 'UHSCSU',
903 'template': "'case' expression may not be of type '#{type}'.",
904 },
905
906 'SWITCH_CASE_VALUE_OVERRIDES_EQUALS': {
907 'id': 'NRTWXL',
908 'template': "'case' expression type '#{type}' overrides 'operator =='.",
909 },
910
911 'INVALID_ARGUMENT_AFTER_NAMED': {
912 'id': 'WAJURC',
913 'template': "Unnamed argument after named argument.",
914 },
915
916 'NOT_A_COMPILE_TIME_CONSTANT': {
917 'id': 'SBCHWL',
918 'template': "Not a compile-time constant.",
919 },
920
921 'DEFERRED_COMPILE_TIME_CONSTANT': {
922 'id': 'FHXTCK',
923 'template': "A deferred value cannot be used as a compile-time constant.",
924 },
925
926 'DEFERRED_COMPILE_TIME_CONSTANT_CONSTRUCTION': {
927 'id': 'TSBXLG',
928 'template': "A deferred class cannot be used to create a "
929 "compile-time constant.",
930 },
931
932 'CYCLIC_COMPILE_TIME_CONSTANTS': {
933 'id': 'JJWJYE',
934 'template': "Cycle in the compile-time constant computation.",
935 },
936
937 'CONSTRUCTOR_IS_NOT_CONST': {
938 'id': 'DOJCUX',
939 'template': "Constructor is not a 'const' constructor.",
940 },
941
942 'CONST_MAP_KEY_OVERRIDES_EQUALS': {
943 'id': 'VJNWEL',
944 'template': "Const-map key type '#{type}' overrides 'operator =='.",
945 },
946
947 'NO_SUCH_LIBRARY_MEMBER': {
948 'id': 'IOXVBA',
949 'template': "'#{libraryName}' has no member named '#{memberName}'.",
950 },
951
952 'CANNOT_INSTANTIATE_TYPEDEF': {
953 'id': 'KOYNMU',
954 'template': "Cannot instantiate typedef '#{typedefName}'.",
955 },
956
957 'REQUIRED_PARAMETER_WITH_DEFAULT': {
958 'id': 'CJWECI',
959 'template': "Non-optional parameters can't have a default value.",
960 'howToFix':
961 "Try removing the default value or making the parameter optional.",
962 'examples': [
963 """
964 main() {
965 foo(a: 1) => print(a);
966 foo(2);
967 }""",
968 """
969 main() {
970 foo(a = 1) => print(a);
971 foo(2);
972 }"""
973 ],
974 },
975
976 'NAMED_PARAMETER_WITH_EQUALS': {
977 'id': 'RPJDXD',
978 'template': "Named optional parameters can't use '=' to specify a default "
979 "value.",
980 'howToFix': "Try replacing '=' with ':'.",
981 'examples': [
982 """
983 main() {
984 foo({a = 1}) => print(a);
985 foo(a: 2);
986 }"""
987 ],
988 },
989
990 'POSITIONAL_PARAMETER_WITH_EQUALS': {
991 'id': 'JMSSDX',
992 'template': "Positional optional parameters can't use ':' to specify a "
993 "default value.",
994 'howToFix': "Try replacing ':' with '='.",
995 'examples': [
996 """
997 main() {
998 foo([a: 1]) => print(a);
999 foo(2);
1000 }"""
1001 ],
1002 },
1003
1004 'TYPEDEF_FORMAL_WITH_DEFAULT': {
1005 'id': 'NABHHS',
1006 'template': "A parameter of a typedef can't specify a default value.",
1007 'howToFix': "Try removing the default value.",
1008 'examples': [
1009 """
1010 typedef void F([int arg = 0]);
1011
1012 main() {
1013 F f;
1014 }""",
1015 """
1016 typedef void F({int arg: 0});
1017
1018 main() {
1019 F f;
1020 }"""
1021 ],
1022 },
1023
1024 'FUNCTION_TYPE_FORMAL_WITH_DEFAULT': {
1025 'id': 'APKYLU',
1026 'template': "A function type parameter can't specify a default value.",
1027 'howToFix': "Try removing the default value.",
1028 'examples': [
1029 """
1030 foo(f(int i, [a = 1])) {}
1031
1032 main() {
1033 foo(1, 2);
1034 }""",
1035 """
1036 foo(f(int i, {a: 1})) {}
1037
1038 main() {
1039 foo(1, a: 2);
1040 }"""
1041 ],
1042 },
1043
1044 'REDIRECTING_FACTORY_WITH_DEFAULT': {
1045 'id': 'AWSSEY',
1046 'template':
1047 "A parameter of a redirecting factory constructor can't specify a "
1048 "default value.",
1049 'howToFix': "Try removing the default value.",
1050 'examples': [
1051 """
1052 class A {
1053 A([a]);
1054 factory A.foo([a = 1]) = A;
1055 }
1056
1057 main() {
1058 new A.foo(1);
1059 }""",
1060 """
1061 class A {
1062 A({a});
1063 factory A.foo({a: 1}) = A;
1064 }
1065
1066 main() {
1067 new A.foo(a: 1);
1068 }"""
1069 ],
1070 },
1071
1072 'FORMAL_DECLARED_CONST': {
1073 'id': 'AVPRDK',
1074 'template': "A formal parameter can't be declared const.",
1075 'howToFix': "Try removing 'const'.",
1076 'examples': [
1077 """
1078 foo(const x) {}
1079 main() => foo(42);
1080 """,
1081 """
1082 foo({const x}) {}
1083 main() => foo(42);
1084 """,
1085 """
1086 foo([const x]) {}
1087 main() => foo(42);
1088 """
1089 ],
1090 },
1091
1092 'FORMAL_DECLARED_STATIC': {
1093 'id': 'PJKDMX',
1094 'template': "A formal parameter can't be declared static.",
1095 'howToFix': "Try removing 'static'.",
1096 'examples': [
1097 """
1098 foo(static x) {}
1099 main() => foo(42);
1100 """,
1101 """
1102 foo({static x}) {}
1103 main() => foo(42);
1104 """,
1105 """
1106 foo([static x]) {}
1107 main() => foo(42);
1108 """
1109 ],
1110 },
1111
1112 'FINAL_FUNCTION_TYPE_PARAMETER': {
1113 'id': 'JIOPIQ',
1114 'template': "A function type parameter can't be declared final.",
1115 'howToFix': "Try removing 'final'.",
1116 'examples': [
1117 """
1118 foo(final int x(int a)) {}
1119 main() => foo((y) => 42);
1120 """,
1121 """
1122 foo({final int x(int a)}) {}
1123 main() => foo((y) => 42);
1124 """,
1125 """
1126 foo([final int x(int a)]) {}
1127 main() => foo((y) => 42);
1128 """
1129 ],
1130 },
1131
1132 'VAR_FUNCTION_TYPE_PARAMETER': {
1133 'id': 'FOQOHK',
1134 'template': "A function type parameter can't be declared with 'var'.",
1135 'howToFix': "Try removing 'var'.",
1136 'examples': [
1137 """
1138 foo(var int x(int a)) {}
1139 main() => foo((y) => 42);
1140 """,
1141 """
1142 foo({var int x(int a)}) {}
1143 main() => foo((y) => 42);
1144 """,
1145 """
1146 foo([var int x(int a)]) {}
1147 main() => foo((y) => 42);
1148 """
1149 ],
1150 },
1151
1152 'CANNOT_INSTANTIATE_TYPE_VARIABLE': {
1153 'id': 'JAYHCH',
1154 'template': "Cannot instantiate type variable '#{typeVariableName}'.",
1155 },
1156
1157 'CYCLIC_TYPE_VARIABLE': {
1158 'id': 'RQMPSO',
1159 'template': "Type variable '#{typeVariableName}' is a supertype of itself.",
1160 },
1161
1162 'CYCLIC_TYPEDEF': {
1163 'id': 'VFERCQ',
1164 'template': "A typedef can't refer to itself.",
1165 'howToFix': "Try removing all references to '#{typedefName}' "
1166 "in the definition of '#{typedefName}'.",
1167 'examples': [
1168 """
1169 typedef F F(); // The return type 'F' is a self-reference.
1170 main() { F f = null; }"""
1171 ],
1172 },
1173
1174 'CYCLIC_TYPEDEF_ONE': {
1175 'id': 'ASWLWR',
1176 'template': "A typedef can't refer to itself through another typedef.",
1177 'howToFix': "Try removing all references to "
1178 "'#{otherTypedefName}' in the definition of '#{typedefName}'.",
1179 'examples': [
1180 """
1181 typedef G F(); // The return type 'G' is a self-reference through typedef 'G'.
1182 typedef F G(); // The return type 'F' is a self-reference through typedef 'F'.
1183 main() { F f = null; }""",
1184 """
1185 typedef G F(); // The return type 'G' creates a self-reference.
1186 typedef H G(); // The return type 'H' creates a self-reference.
1187 typedef H(F f); // The argument type 'F' creates a self-reference.
1188 main() { F f = null; }"""
1189 ],
1190 },
1191
1192 'CLASS_NAME_EXPECTED': {'id': 'DPKNHY', 'template': "Class name expected.",},
1193
1194 'CANNOT_EXTEND': {
1195 'id': 'GCIQXD',
1196 'template': "'#{type}' cannot be extended.",
1197 },
1198
1199 'CANNOT_IMPLEMENT': {
1200 'id': 'IBOQKV',
1201 'template': "'#{type}' cannot be implemented.",
1202 },
1203
1204 // TODO(johnnwinther): Split messages into reasons for malformedness.
1205 'CANNOT_EXTEND_MALFORMED': {
1206 'id': 'YPFJBD',
1207 'template': "Class '#{className}' can't extend the type '#{malformedType}' "
1208 "because it is malformed.",
1209 'howToFix': "Try correcting the malformed type annotation or removing the "
1210 "'extends' clause.",
1211 'examples': [
1212 """
1213 class A extends Malformed {}
1214 main() => new A();"""
1215 ],
1216 },
1217
1218 'CANNOT_IMPLEMENT_MALFORMED': {
1219 'id': 'XJUIAQ',
1220 'template':
1221 "Class '#{className}' can't implement the type '#{malformedType}' "
1222 "because it is malformed.",
1223 'howToFix': "Try correcting the malformed type annotation or removing the "
1224 "type from the 'implements' clause.",
1225 'examples': [
1226 """
1227 class A implements Malformed {}
1228 main() => new A();"""
1229 ],
1230 },
1231
1232 'CANNOT_MIXIN_MALFORMED': {
1233 'id': 'SSMNXN',
1234 'template': "Class '#{className}' can't mixin the type '#{malformedType}' "
1235 "because it is malformed.",
1236 'howToFix': "Try correcting the malformed type annotation or removing the "
1237 "type from the 'with' clause.",
1238 'examples': [
1239 """
1240 class A extends Object with Malformed {}
1241 main() => new A();"""
1242 ],
1243 },
1244
1245 'CANNOT_MIXIN': {
1246 'id': 'KLSXDQ',
1247 'template': "The type '#{type}' can't be mixed in.",
1248 'howToFix': "Try removing '#{type}' from the 'with' clause.",
1249 'examples': [
1250 """
1251 class C extends Object with String {}
1252
1253 main() => new C();
1254 """,
1255 """
1256 typedef C = Object with String;
1257
1258 main() => new C();
1259 """
1260 ],
1261 },
1262
1263 'CANNOT_EXTEND_ENUM': {
1264 'id': 'JEPRST',
1265 'template':
1266 "Class '#{className}' can't extend the type '#{enumType}' because "
1267 "it is declared by an enum.",
1268 'howToFix': "Try making '#{enumType}' a normal class or removing the "
1269 "'extends' clause.",
1270 'examples': [
1271 """
1272 enum Enum { A }
1273 class B extends Enum {}
1274 main() => new B();"""
1275 ],
1276 },
1277
1278 'CANNOT_IMPLEMENT_ENUM': {
1279 'id': 'JMJMSH',
1280 'template': "Class '#{className}' can't implement the type '#{enumType}' "
1281 "because it is declared by an enum.",
1282 'howToFix': "Try making '#{enumType}' a normal class or removing the "
1283 "type from the 'implements' clause.",
1284 'examples': [
1285 """
1286 enum Enum { A }
1287 class B implements Enum {}
1288 main() => new B();"""
1289 ],
1290 },
1291
1292 'CANNOT_MIXIN_ENUM': {
1293 'id': 'YSYDIM',
1294 'template':
1295 "Class '#{className}' can't mixin the type '#{enumType}' because it "
1296 "is declared by an enum.",
1297 'howToFix': "Try making '#{enumType}' a normal class or removing the "
1298 "type from the 'with' clause.",
1299 'examples': [
1300 """
1301 enum Enum { A }
1302 class B extends Object with Enum {}
1303 main() => new B();"""
1304 ],
1305 },
1306
1307 'CANNOT_INSTANTIATE_ENUM': {
1308 'id': 'CQYIFU',
1309 'template': "Enum type '#{enumName}' cannot be instantiated.",
1310 'howToFix': "Try making '#{enumType}' a normal class or use an enum "
1311 "constant.",
1312 'examples': [
1313 """
1314 enum Enum { A }
1315 main() => new Enum(0);""",
1316 """
1317 enum Enum { A }
1318 main() => const Enum(0);"""
1319 ],
1320 },
1321
1322 'EMPTY_ENUM_DECLARATION': {
1323 'id': 'JFPDOH',
1324 'template': "Enum '#{enumName}' must contain at least one value.",
1325 'howToFix': "Try adding an enum constant or making #{enumName} a "
1326 "normal class.",
1327 'examples': [
1328 """
1329 enum Enum {}
1330 main() { Enum e; }"""
1331 ],
1332 },
1333
1334 'MISSING_ENUM_CASES': {
1335 'id': 'HHEOIW',
1336 'template': "Missing enum constants in switch statement: #{enumValues}.",
1337 'howToFix': "Try adding the missing constants or a default case.",
1338 'examples': [
1339 """
1340 enum Enum { A, B }
1341 main() {
1342 switch (Enum.A) {
1343 case Enum.B: break;
1344 }
1345 }""",
1346 """
1347 enum Enum { A, B, C }
1348 main() {
1349 switch (Enum.A) {
1350 case Enum.B: break;
1351 }
1352 }"""
1353 ],
1354 },
1355
1356 'DUPLICATE_EXTENDS_IMPLEMENTS': {
1357 'id': 'BKRKEO',
1358 'template': "'#{type}' can not be both extended and implemented.",
1359 },
1360
1361 'DUPLICATE_IMPLEMENTS': {
1362 'id': 'IWJFTU',
1363 'template': "'#{type}' must not occur more than once "
1364 "in the implements clause.",
1365 },
1366
1367 'MULTI_INHERITANCE': {
1368 'id': 'NWXGOI',
1369 'template':
1370 "Dart2js does not currently support inheritance of the same class "
1371 "with different type arguments: Both #{firstType} and #{secondType} "
1372 "are supertypes of #{thisType}.",
1373 },
1374
1375 'ILLEGAL_SUPER_SEND': {
1376 'id': 'LDRGIU',
1377 'template': "'#{name}' cannot be called on super.",
1378 },
1379
1380 'NO_SUCH_SUPER_MEMBER': {
1381 'id': 'HIJJVG',
1382 'template':
1383 "Cannot resolve '#{memberName}' in a superclass of '#{className}'.",
1384 },
1385
1386 'ADDITIONAL_TYPE_ARGUMENT': {
1387 'id': 'HWYHWH',
1388 'template': "Additional type argument.",
1389 },
1390
1391 'MISSING_TYPE_ARGUMENT': {
1392 'id': 'KYTQWA',
1393 'template': "Missing type argument.",
1394 },
1395
1396 // TODO(johnniwinther): Use ADDITIONAL_TYPE_ARGUMENT or
1397 // MISSING_TYPE_ARGUMENT instead.
1398 'TYPE_ARGUMENT_COUNT_MISMATCH': {
1399 'id': 'ECXGRM',
1400 'template': "Incorrect number of type arguments on '#{type}'.",
1401 },
1402
1403 'GETTER_MISMATCH': {
1404 'id': 'MNODFW',
1405 'template': "Setter disagrees on: '#{modifiers}'.",
1406 },
1407
1408 'SETTER_MISMATCH': {
1409 'id': 'FMNHPL',
1410 'template': "Getter disagrees on: '#{modifiers}'.",
1411 },
1412
1413 'ILLEGAL_SETTER_FORMALS': {
1414 'id': 'COTPVN',
1415 'template': "A setter must have exactly one argument.",
1416 },
1417
1418 'NO_STATIC_OVERRIDE': {
1419 'id': 'EHINXB',
1420 'template':
1421 "Static member cannot override instance member '#{memberName}' of "
1422 "'#{className}'.",
1423 },
1424
1425 'NO_STATIC_OVERRIDE_CONT': {
1426 'id': 'TEVJMA',
1427 'template': "This is the instance member that cannot be overridden "
1428 "by a static member.",
1429 },
1430
1431 'INSTANCE_STATIC_SAME_NAME': {
1432 'id': 'LTBFBO',
1433 'template': "Instance member '#{memberName}' and static member of "
1434 "superclass '#{className}' have the same name.",
1435 },
1436
1437 'INSTANCE_STATIC_SAME_NAME_CONT': {
1438 'id': 'CHSUCQ',
1439 'template': "This is the static member with the same name.",
1440 },
1441
1442 'INVALID_OVERRIDE_METHOD': {
1443 'id': 'NINKPI',
1444 'template': "The type '#{declaredType}' of method '#{name}' declared in "
1445 "'#{class}' is not a subtype of the overridden method type "
1446 "'#{inheritedType}' inherited from '#{inheritedClass}'.",
1447 },
1448
1449 'INVALID_OVERRIDDEN_METHOD': {
1450 'id': 'BQHUPY',
1451 'template': "This is the overridden method '#{name}' declared in class "
1452 "'#{class}'.",
1453 },
1454
1455 'INVALID_OVERRIDE_GETTER': {
1456 'id': 'KLMPWO',
1457 'template': "The type '#{declaredType}' of getter '#{name}' declared in "
1458 "'#{class}' is not assignable to the type '#{inheritedType}' of the "
1459 "overridden getter inherited from '#{inheritedClass}'.",
1460 },
1461
1462 'INVALID_OVERRIDDEN_GETTER': {
1463 'id': 'ASSKCT',
1464 'template': "This is the overridden getter '#{name}' declared in class "
1465 "'#{class}'.",
1466 },
1467
1468 'INVALID_OVERRIDE_GETTER_WITH_FIELD': {
1469 'id': 'TCCGXU',
1470 'template': "The type '#{declaredType}' of field '#{name}' declared in "
1471 "'#{class}' is not assignable to the type '#{inheritedType}' of the "
1472 "overridden getter inherited from '#{inheritedClass}'.",
1473 },
1474
1475 'INVALID_OVERRIDE_FIELD_WITH_GETTER': {
1476 'id': 'UMMEXO',
1477 'template': "The type '#{declaredType}' of getter '#{name}' declared in "
1478 "'#{class}' is not assignable to the type '#{inheritedType}' of the "
1479 "overridden field inherited from '#{inheritedClass}'.",
1480 },
1481
1482 'INVALID_OVERRIDE_SETTER': {
1483 'id': 'BWRGEC',
1484 'template': "The type '#{declaredType}' of setter '#{name}' declared in "
1485 "'#{class}' is not assignable to the type '#{inheritedType}' of the "
1486 "overridden setter inherited from '#{inheritedClass}'.",
1487 },
1488
1489 'INVALID_OVERRIDDEN_SETTER': {
1490 'id': 'XQUOLL',
1491 'template': "This is the overridden setter '#{name}' declared in class "
1492 "'#{class}'.",
1493 },
1494
1495 'INVALID_OVERRIDE_SETTER_WITH_FIELD': {
1496 'id': 'GKGOFA',
1497 'template': "The type '#{declaredType}' of field '#{name}' declared in "
1498 "'#{class}' is not assignable to the type '#{inheritedType}' of the "
1499 "overridden setter inherited from '#{inheritedClass}'.",
1500 },
1501
1502 'INVALID_OVERRIDE_FIELD_WITH_SETTER': {
1503 'id': 'OOXKHQ',
1504 'template': "The type '#{declaredType}' of setter '#{name}' declared in "
1505 "'#{class}' is not assignable to the type '#{inheritedType}' of the "
1506 "overridden field inherited from '#{inheritedClass}'.",
1507 },
1508
1509 'INVALID_OVERRIDE_FIELD': {
1510 'id': 'LDPKOL',
1511 'template': "The type '#{declaredType}' of field '#{name}' declared in "
1512 "'#{class}' is not assignable to the type '#{inheritedType}' of the "
1513 "overridden field inherited from '#{inheritedClass}'.",
1514 },
1515
1516 'INVALID_OVERRIDDEN_FIELD': {
1517 'id': 'UNQFWX',
1518 'template': "This is the overridden field '#{name}' declared in class "
1519 "'#{class}'.",
1520 },
1521
1522 'CANNOT_OVERRIDE_FIELD_WITH_METHOD': {
1523 'id': 'SYKCSK',
1524 'template': "Method '#{name}' in '#{class}' can't override field from "
1525 "'#{inheritedClass}'.",
1526 },
1527
1528 'CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT': {
1529 'id': 'HYHQSO',
1530 'template': "This is the field that cannot be overridden by a method.",
1531 },
1532
1533 'CANNOT_OVERRIDE_METHOD_WITH_FIELD': {
1534 'id': 'UROMAS',
1535 'template': "Field '#{name}' in '#{class}' can't override method from "
1536 "'#{inheritedClass}'.",
1537 },
1538
1539 'CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT': {
1540 'id': 'NSORYS',
1541 'template': "This is the method that cannot be overridden by a field.",
1542 },
1543
1544 'CANNOT_OVERRIDE_GETTER_WITH_METHOD': {
1545 'id': 'MMFIOH',
1546 'template': "Method '#{name}' in '#{class}' can't override getter from "
1547 "'#{inheritedClass}'.",
1548 },
1549
1550 'CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT': {
1551 'id': 'YGWPDH',
1552 'template': "This is the getter that cannot be overridden by a method.",
1553 },
1554
1555 'CANNOT_OVERRIDE_METHOD_WITH_GETTER': {
1556 'id': 'BNKNXO',
1557 'template': "Getter '#{name}' in '#{class}' can't override method from "
1558 "'#{inheritedClass}'.",
1559 },
1560
1561 'CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT': {
1562 'id': 'KFBCYX',
1563 'template': "This is the method that cannot be overridden by a getter.",
1564 },
1565
1566 'MISSING_FORMALS': {
1567 'id': 'BOERAF',
1568 'template': "Formal parameters are missing.",
1569 },
1570
1571 'EXTRA_FORMALS': {
1572 'id': 'UTWRIU',
1573 'template': "Formal parameters are not allowed here.",
1574 },
1575
1576 'UNARY_OPERATOR_BAD_ARITY': {
1577 'id': 'TNHLAL',
1578 'template': "Operator '#{operatorName}' must have no parameters.",
1579 },
1580
1581 'MINUS_OPERATOR_BAD_ARITY': {
1582 'id': 'SXDRRU',
1583 'template': "Operator '-' must have 0 or 1 parameters.",
1584 },
1585
1586 'BINARY_OPERATOR_BAD_ARITY': {
1587 'id': 'QKWAUM',
1588 'template': "Operator '#{operatorName}' must have exactly 1 parameter.",
1589 },
1590
1591 'TERNARY_OPERATOR_BAD_ARITY': {
1592 'id': 'LSMQGF',
1593 'template': "Operator '#{operatorName}' must have exactly 2 parameters.",
1594 },
1595
1596 'OPERATOR_OPTIONAL_PARAMETERS': {
1597 'id': 'HSGRBV',
1598 'template': "Operator '#{operatorName}' cannot have optional parameters.",
1599 },
1600
1601 'OPERATOR_NAMED_PARAMETERS': {
1602 'id': 'EACWGS',
1603 'template': "Operator '#{operatorName}' cannot have named parameters.",
1604 },
1605
1606 'CONSTRUCTOR_WITH_RETURN_TYPE': {
1607 'id': 'OPMBHF',
1608 'template': "Cannot have return type for constructor.",
1609 },
1610
1611 'CANNOT_RETURN_FROM_CONSTRUCTOR': {
1612 'id': 'NFUGNH',
1613 'template': "Constructors can't return values.",
1614 'howToFix': "Remove the return statement or use a factory constructor.",
1615 'examples': [
1616 """
1617 class C {
1618 C() {
1619 return 1;
1620 }
1621 }
1622
1623 main() => new C();"""
1624 ],
1625 },
1626
1627 'ILLEGAL_FINAL_METHOD_MODIFIER': {
1628 'id': 'YUKCVU',
1629 'template': "Cannot have final modifier on method.",
1630 },
1631
1632 'ILLEGAL_CONST_FIELD_MODIFIER': {
1633 'id': 'JGFAGV',
1634 'template': "Cannot have const modifier on non-static field.",
1635 'howToFix': "Try adding a static modifier, or removing the const modifier.",
1636 'examples': [
1637 """
1638 class C {
1639 const int a = 1;
1640 }
1641
1642 main() => new C();"""
1643 ],
1644 },
1645
1646 'ILLEGAL_CONSTRUCTOR_MODIFIERS': {
1647 'id': 'WODRHN',
1648 'template': "Illegal constructor modifiers: '#{modifiers}'.",
1649 },
1650
1651 'ILLEGAL_MIXIN_APPLICATION_MODIFIERS': {
1652 'id': 'OFLFHN',
1653 'template': "Illegal mixin application modifiers: '#{modifiers}'.",
1654 },
1655
1656 'ILLEGAL_MIXIN_SUPERCLASS': {
1657 'id': 'TPVVYN',
1658 'template': "Class used as mixin must have Object as superclass.",
1659 },
1660
1661 'ILLEGAL_MIXIN_OBJECT': {
1662 'id': 'CMVTLF',
1663 'template': "Cannot use Object as mixin.",
1664 },
1665
1666 'ILLEGAL_MIXIN_CONSTRUCTOR': {
1667 'id': 'HXBUIB',
1668 'template': "Class used as mixin cannot have non-factory constructor.",
1669 },
1670
1671 'ILLEGAL_MIXIN_CYCLE': {
1672 'id': 'ANXAMU',
1673 'template': "Class used as mixin introduces mixin cycle: "
1674 "'#{mixinName1}' <-> '#{mixinName2}'.",
1675 },
1676
1677 'ILLEGAL_MIXIN_WITH_SUPER': {
1678 'id': 'KIEUGK',
1679 'template': "Cannot use class '#{className}' as a mixin because it uses "
1680 "'super'.",
1681 },
1682
1683 'ILLEGAL_MIXIN_SUPER_USE': {
1684 'id': 'QKUPLH',
1685 'template': "Use of 'super' in class used as mixin.",
1686 },
1687
1688 'PARAMETER_NAME_EXPECTED': {
1689 'id': 'JOUOBT',
1690 'template': "parameter name expected.",
1691 },
1692
1693 'CANNOT_RESOLVE_GETTER': {
1694 'id': 'TDHKSW',
1695 'template': "Cannot resolve getter.",
1696 },
1697
1698 'CANNOT_RESOLVE_SETTER': {
1699 'id': 'QQFANP',
1700 'template': "Cannot resolve setter.",
1701 },
1702
1703 'ASSIGNING_FINAL_FIELD_IN_SUPER': {
1704 'id': 'LXUPCC',
1705 'template': "Cannot assign a value to final field '#{name}' "
1706 "in superclass '#{superclassName}'.",
1707 },
1708
1709 'ASSIGNING_METHOD': {
1710 'id': 'JUVMYC',
1711 'template': "Cannot assign a value to a method.",
1712 },
1713
1714 'ASSIGNING_METHOD_IN_SUPER': {
1715 'id': 'AGMAXN',
1716 'template': "Cannot assign a value to method '#{name}' "
1717 "in superclass '#{superclassName}'.",
1718 },
1719
1720 'ASSIGNING_TYPE': {
1721 'id': 'VXTPWE',
1722 'template': "Cannot assign a value to a type.",
1723 },
1724
1725 'IF_NULL_ASSIGNING_TYPE': {
1726 'id': 'XBRHGK',
1727 'template':
1728 "Cannot assign a value to a type. Note that types are never null, "
1729 "so this ??= assignment has no effect.",
1730 'howToFix': "Try removing the '??=' assignment.",
1731 'examples': ["class A {} main() { print(A ??= 3);}",],
1732 },
1733
1734 'VOID_NOT_ALLOWED': {
1735 'id': 'DMMDXT',
1736 'template':
1737 "Type 'void' can't be used here because it isn't a return type.",
1738 'howToFix':
1739 "Try removing 'void' keyword or replace it with 'var', 'final', "
1740 "or a type.",
1741 'examples': ["void x; main() {}", "foo(void x) {} main() { foo(null); }",],
1742 },
1743
1744 'NULL_NOT_ALLOWED': {
1745 'id': 'STYNSK',
1746 'template': "`null` can't be used here.",
1747 },
1748
1749 'BEFORE_TOP_LEVEL': {
1750 'id': 'GRCXQF',
1751 'template': "Part header must come before top-level definitions.",
1752 },
1753
1754 'IMPORT_PART_OF': {
1755 'id': 'VANCWE',
1756 'template': "The imported library must not have a 'part-of' directive.",
1757 'howToFix': "Try removing the 'part-of' directive or replacing the "
1758 "import of the library with a 'part' directive.",
1759 'examples': [
1760 {
1761 'main.dart': """
1762 library library;
1763
1764 import 'part.dart';
1765
1766 main() {}
1767 """,
1768 'part.dart': """
1769 part of library;
1770 """
1771 }
1772 ],
1773 },
1774
1775 'LIBRARY_NAME_MISMATCH': {
1776 'id': 'AXGYPQ',
1777 'template': "Expected part of library name '#{libraryName}'.",
1778 'howToFix': "Try changing the directive to 'part of #{libraryName};'.",
1779 'examples': [
1780 {
1781 'main.dart': """
1782 library lib.foo;
1783
1784 part 'part.dart';
1785
1786 main() {}
1787 """,
1788 'part.dart': """
1789 part of lib.bar;
1790 """
1791 }
1792 ],
1793 },
1794
1795 'MISSING_LIBRARY_NAME': {
1796 'id': 'NYQNCA',
1797 'template': "Library has no name. Part directive expected library name "
1798 "to be '#{libraryName}'.",
1799 'howToFix': "Try adding 'library #{libraryName};' to the library.",
1800 'examples': [
1801 {
1802 'main.dart': """
1803 part 'part.dart';
1804
1805 main() {}
1806 """,
1807 'part.dart': """
1808 part of lib.foo;
1809 """
1810 }
1811 ],
1812 },
1813
1814 'THIS_IS_THE_PART_OF_TAG': {
1815 'id': 'RPSJRS',
1816 'template': "This is the part of directive.",
1817 },
1818
1819 'MISSING_PART_OF_TAG': {
1820 'id': 'QNYCMV',
1821 'template': "This file has no part-of tag, but it is being used as a part.",
1822 },
1823
1824 'DUPLICATED_PART_OF': {
1825 'id': 'UJDYHF',
1826 'template': "Duplicated part-of directive.",
1827 },
1828
1829 'DUPLICATED_LIBRARY_NAME': {
1830 'id': 'OSEHXI',
1831 'template': "Duplicated library name '#{libraryName}'.",
1832 },
1833
1834 'DUPLICATED_RESOURCE': {
1835 'id': 'UFWKBY',
1836 'template': "The resource '#{resourceUri}' is loaded through both "
1837 "'#{canonicalUri1}' and '#{canonicalUri2}'.",
1838 },
1839
1840 'DUPLICATED_LIBRARY_RESOURCE': {
1841 'id': 'KYGYTT',
1842 'template':
1843 "The library '#{libraryName}' in '#{resourceUri}' is loaded through "
1844 "both '#{canonicalUri1}' and '#{canonicalUri2}'.",
1845 },
1846
1847 // This is used as an exception.
1848 'INVALID_SOURCE_FILE_LOCATION': {
1849 'id': 'WIGJFG',
1850 'template': """
1851 Invalid offset (#{offset}) in source map.
1852 File: #{fileName}
1853 Length: #{length}""",
1854 },
1855
1856 'TOP_LEVEL_VARIABLE_DECLARED_STATIC': {
1857 'id': 'IVNDML',
1858 'template': "Top-level variable cannot be declared static.",
1859 },
1860
1861 'REFERENCE_IN_INITIALIZATION': {
1862 'id': 'OVWTEU',
1863 'template': "Variable '#{variableName}' is referenced during its "
1864 "initialization.",
1865 'howToFix': "If you are trying to reference a shadowed variable, rename "
1866 "one of the variables.",
1867 'examples': [
1868 """
1869 foo(t) {
1870 var t = t;
1871 return t;
1872 }
1873
1874 main() => foo(1);
1875 """
1876 ],
1877 },
1878
1879 'CONST_WITHOUT_INITIALIZER': {
1880 'id': 'UDWCNH',
1881 'template': "A constant variable must be initialized.",
1882 'howToFix': "Try adding an initializer or "
1883 "removing the 'const' modifier.",
1884 'examples': [
1885 """
1886 void main() {
1887 const c; // This constant variable must be initialized.
1888 }"""
1889 ],
1890 },
1891
1892 'FINAL_WITHOUT_INITIALIZER': {
1893 'id': 'YMESFI',
1894 'template': "A final variable must be initialized.",
1895 'howToFix': "Try adding an initializer or "
1896 "removing the 'final' modifier.",
1897 'examples': ["class C { static final field; } main() => C.field;"],
1898 },
1899
1900 'MEMBER_USES_CLASS_NAME': {
1901 'id': 'TVFYRK',
1902 'template': "Member variable can't have the same name as the class it is "
1903 "declared in.",
1904 'howToFix': "Try renaming the variable.",
1905 'examples': [
1906 """
1907 class A { var A; }
1908 main() {
1909 var a = new A();
1910 a.A = 1;
1911 }
1912 """,
1913 """
1914 class A { static var A; }
1915 main() => A.A = 1;
1916 """
1917 ],
1918 },
1919
1920 'WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT': {
1921 'id': 'IXYNUF',
1922 'template': "Wrong number of arguments to assert. Should be 1, but given "
1923 "#{argumentCount}.",
1924 },
1925
1926 'ASSERT_IS_GIVEN_NAMED_ARGUMENTS': {
1927 'id': 'EJFDTO',
1928 'template':
1929 "'assert' takes no named arguments, but given #{argumentCount}.",
1930 },
1931
1932 'FACTORY_REDIRECTION_IN_NON_FACTORY': {
1933 'id': 'DTBWEX',
1934 'template': "Factory redirection only allowed in factories.",
1935 },
1936
1937 'MISSING_FACTORY_KEYWORD': {
1938 'id': 'HOQYYA',
1939 'template': "Did you forget a factory keyword here?",
1940 },
1941
1942 'NO_SUCH_METHOD_IN_NATIVE': {
1943 'id': 'MSDDBX',
1944 'template':
1945 "'NoSuchMethod' is not supported for classes that extend native "
1946 "classes.",
1947 },
1948
1949 'DEFERRED_LIBRARY_DART_2_DART': {
1950 'id': 'RIRQAH',
1951 'template': "Deferred loading is not supported by the dart backend yet. "
1952 "The output will not be split.",
1953 },
1954
1955 'DEFERRED_LIBRARY_WITHOUT_PREFIX': {
1956 'id': 'CARRII',
1957 'template': "This import is deferred but there is no prefix keyword.",
1958 'howToFix': "Try adding a prefix to the import."
1959 },
1960
1961 'DEFERRED_OLD_SYNTAX': {
1962 'id': 'QCBRAE',
1963 'template': "The DeferredLibrary annotation is obsolete.",
1964 'howToFix':
1965 "Use the \"import 'lib.dart' deferred as prefix\" syntax instead.",
1966 },
1967
1968 'DEFERRED_LIBRARY_DUPLICATE_PREFIX': {
1969 'id': 'BBMJTD',
1970 'template': "The prefix of this deferred import is not unique.",
1971 'howToFix': "Try changing the import prefix."
1972 },
1973
1974 'DEFERRED_TYPE_ANNOTATION': {
1975 'id': 'JOUEFD',
1976 'template': "The type #{node} is deferred. "
1977 "Deferred types are not valid as type annotations.",
1978 'howToFix': "Try using a non-deferred abstract class as an interface.",
1979 },
1980
1981 'ILLEGAL_STATIC': {
1982 'id': 'HFBHVE',
1983 'template': "Modifier static is only allowed on functions declared in "
1984 "a class.",
1985 },
1986
1987 'STATIC_FUNCTION_BLOAT': {
1988 'id': 'SJHTKF',
1989 'template': "Using '#{class}.#{name}' may lead to unnecessarily large "
1990 "generated code.",
1991 'howToFix': "Try adding '@MirrorsUsed(...)' as described at "
1992 "https://goo.gl/Akrrog.",
1993 },
1994
1995 'NON_CONST_BLOAT': {
1996 'id': 'RDRSHO',
1997 'template': "Using 'new #{name}' may lead to unnecessarily large generated "
1998 "code.",
1999 'howToFix': "Try using 'const #{name}' or adding '@MirrorsUsed(...)' as "
2000 "described at https://goo.gl/Akrrog.",
2001 },
2002
2003 'STRING_EXPECTED': {
2004 'id': 'OEJOOI',
2005 'template': "Expected a 'String', but got an instance of '#{type}'.",
2006 },
2007
2008 'PRIVATE_IDENTIFIER': {
2009 'id': 'XAHVWI',
2010 'template': "'#{value}' is not a valid Symbol name because it starts with "
2011 "'_'.",
2012 },
2013
2014 'PRIVATE_NAMED_PARAMETER': {
2015 'id': 'VFGCLK',
2016 'template': "Named optional parameter can't have a library private name.",
2017 'howToFix': "Try removing the '_' or making the parameter positional or "
2018 "required.",
2019 'examples': ["""foo({int _p}) {} main() => foo();"""],
2020 },
2021
2022 'UNSUPPORTED_LITERAL_SYMBOL': {
2023 'id': 'OYCDII',
2024 'template':
2025 "Symbol literal '##{value}' is currently unsupported by dart2js.",
2026 },
2027
2028 'INVALID_SYMBOL': {
2029 'id': 'RUXMBL',
2030 'template': '''
2031 '#{value}' is not a valid Symbol name because is not:
2032 * an empty String,
2033 * a user defined operator,
2034 * a qualified non-private identifier optionally followed by '=', or
2035 * a qualified non-private identifier followed by '.' and a user-defined '''
2036 "operator.",
2037 },
2038
2039 'AMBIGUOUS_REEXPORT': {
2040 'id': 'YNTOND',
2041 'template': "'#{name}' is (re)exported by multiple libraries.",
2042 },
2043
2044 'AMBIGUOUS_LOCATION': {
2045 'id': 'SKLTYA',
2046 'template': "'#{name}' is defined here.",
2047 },
2048
2049 'IMPORTED_HERE': {'id': 'IMUXAE', 'template': "'#{name}' is imported here.",},
2050
2051 'OVERRIDE_EQUALS_NOT_HASH_CODE': {
2052 'id': 'MUHYXI',
2053 'template': "The class '#{class}' overrides 'operator==', "
2054 "but not 'get hashCode'.",
2055 },
2056
2057 'INTERNAL_LIBRARY_FROM': {
2058 'id': 'RXOCLX',
2059 'template': "Internal library '#{resolvedUri}' is not accessible from "
2060 "'#{importingUri}'.",
2061 },
2062
2063 'INTERNAL_LIBRARY': {
2064 'id': 'SYLJAV',
2065 'template': "Internal library '#{resolvedUri}' is not accessible.",
2066 },
2067
2068 'JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS': {
2069 'id': 'LSHKJK',
2070 'template':
2071 "Js-interop class '#{cls}' cannot extend from the non js-interop "
2072 "class '#{superclass}'.",
2073 'howToFix': "Annotate the superclass with @JS.",
2074 'examples': [
2075 """
2076 import 'package:js/js.dart';
2077
2078 class Foo { }
2079
2080 @JS()
2081 class Bar extends Foo { }
2082
2083 main() {
2084 new Bar();
2085 }
2086 """
2087 ],
2088 },
2089
2090 'JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER': {
2091 'id': 'QLLLEE',
2092 'template':
2093 "Member '#{member}' in js-interop class '#{cls}' is not external.",
2094 'howToFix': "Mark all interop methods external",
2095 'examples': [
2096 """
2097 import 'package:js/js.dart';
2098
2099 @JS()
2100 class Foo {
2101 bar() {}
2102 }
2103
2104 main() {
2105 new Foo().bar();
2106 }
2107 """
2108 ],
2109 },
2110
2111 'JS_INTEROP_METHOD_WITH_NAMED_ARGUMENTS': {
2112 'id': 'TDQHRY',
2113 'template': "Js-interop method '#{method}' has named arguments but is not "
2114 "a factory constructor of an @anonymous @JS class.",
2115 'howToFix': "Remove all named arguments from js-interop method or "
2116 "in the case of a factory constructor annotate the class "
2117 "as @anonymous.",
2118 'examples': [
2119 """
2120 import 'package:js/js.dart';
2121
2122 @JS()
2123 class Foo {
2124 external bar(foo, {baz});
2125 }
2126
2127 main() {
2128 new Foo().bar(4, baz: 5);
2129 }
2130 """
2131 ],
2132 },
2133
2134 'JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS': {
2135 'id': 'EHEKUY',
2136 'template':
2137 "Parameter '#{parameter}' in anonymous js-interop class '#{cls}' "
2138 "object literal constructor is positional instead of named."
2139 ".",
2140 'howToFix': "Make all arguments in external factory object literal "
2141 "constructors named.",
2142 'examples': [
2143 """
2144 import 'package:js/js.dart';
2145
2146 @anonymous
2147 @JS()
2148 class Foo {
2149 external factory Foo(foo, {baz});
2150 }
2151
2152 main() {
2153 new Foo(5, baz: 5);
2154 }
2155 """
2156 ],
2157 },
2158
2159 'LIBRARY_NOT_FOUND': {
2160 'id': 'BARPSL',
2161 'template': "Library not found '#{resolvedUri}'.",
2162 },
2163
2164 'LIBRARY_NOT_SUPPORTED': {
2165 'id': 'GDXUNS',
2166 'template': "Library not supported '#{resolvedUri}'.",
2167 'howToFix': "Try removing the dependency or enabling support using "
2168 "the '--categories' option.",
2169 'examples': [
2170 // """
2171 // import 'dart:io';
2172 // main() {}
2173 // """
2174 ],
2175 // TODO(johnniwinther): Enable example when message_kind_test.dart
2176 // supports library loader callbacks.
2177 },
2178
2179 'UNSUPPORTED_EQ_EQ_EQ': {
2180 'id': 'GPOVNO',
2181 'template': "'===' is not an operator. "
2182 "Did you mean '#{lhs} == #{rhs}' or 'identical(#{lhs}, #{rhs})'?",
2183 },
2184
2185 'UNSUPPORTED_BANG_EQ_EQ': {
2186 'id': 'HDYKMV',
2187 'template': "'!==' is not an operator. "
2188 "Did you mean '#{lhs} != #{rhs}' or '!identical(#{lhs}, #{rhs})'?",
2189 },
2190
2191 'UNSUPPORTED_PREFIX_PLUS': {
2192 'id': 'LSQTHP',
2193 'template': "'+' is not a prefix operator. ",
2194 'howToFix': "Try removing '+'.",
2195 'examples': ["main() => +2; // No longer a valid way to write '2'"],
2196 },
2197
2198 'UNSUPPORTED_THROW_WITHOUT_EXP': {
2199 'id': 'QOAKGE',
2200 'template': "No expression after 'throw'. "
2201 "Did you mean 'rethrow'?",
2202 },
2203
2204 'DEPRECATED_TYPEDEF_MIXIN_SYNTAX': {
2205 'id': 'BBGGFE',
2206 'template': "'typedef' not allowed here. ",
2207 'howToFix': "Try replacing 'typedef' with 'class'.",
2208 'examples': [
2209 """
2210 class B { }
2211 class M1 { }
2212 typedef C = B with M1; // Need to replace 'typedef' with 'class'.
2213 main() { new C(); }
2214 """
2215 ],
2216 },
2217
2218 'MIRRORS_EXPECTED_STRING': {
2219 'id': 'XSKTIB',
2220 'template':
2221 "Can't use '#{name}' here because it's an instance of '#{type}' "
2222 "and a 'String' value is expected.",
2223 'howToFix': "Did you forget to add quotes?",
2224 'examples': [
2225 """
2226 // 'Foo' is a type literal, not a string.
2227 @MirrorsUsed(symbols: const [Foo])
2228 import 'dart:mirrors';
2229
2230 class Foo {}
2231
2232 main() {}
2233 """
2234 ],
2235 },
2236
2237 'MIRRORS_EXPECTED_STRING_OR_TYPE': {
2238 'id': 'JQDJPL',
2239 'template':
2240 "Can't use '#{name}' here because it's an instance of '#{type}' "
2241 "and a 'String' or 'Type' value is expected.",
2242 'howToFix': "Did you forget to add quotes?",
2243 'examples': [
2244 """
2245 // 'main' is a method, not a class.
2246 @MirrorsUsed(targets: const [main])
2247 import 'dart:mirrors';
2248
2249 main() {}
2250 """
2251 ],
2252 },
2253
2254 'MIRRORS_EXPECTED_STRING_OR_LIST': {
2255 'id': 'UVYCOE',
2256 'template':
2257 "Can't use '#{name}' here because it's an instance of '#{type}' "
2258 "and a 'String' or 'List' value is expected.",
2259 'howToFix': "Did you forget to add quotes?",
2260 'examples': [
2261 """
2262 // 'Foo' is not a string.
2263 @MirrorsUsed(symbols: Foo)
2264 import 'dart:mirrors';
2265
2266 class Foo {}
2267
2268 main() {}
2269 """
2270 ],
2271 },
2272
2273 'MIRRORS_EXPECTED_STRING_TYPE_OR_LIST': {
2274 'id': 'WSYDFL',
2275 'template':
2276 "Can't use '#{name}' here because it's an instance of '#{type}' "
2277 "but a 'String', 'Type', or 'List' value is expected.",
2278 'howToFix': "Did you forget to add quotes?",
2279 'examples': [
2280 """
2281 // '1' is not a string.
2282 @MirrorsUsed(targets: 1)
2283 import 'dart:mirrors';
2284
2285 main() {}
2286 """
2287 ],
2288 },
2289
2290 'MIRRORS_CANNOT_RESOLVE_IN_CURRENT_LIBRARY': {
2291 'id': 'VDBBNE',
2292 'template': "Can't find '#{name}' in the current library.",
2293 // TODO(ahe): The closest identifiers in edit distance would be nice.
2294 'howToFix': "Did you forget to add an import?",
2295 'examples': [
2296 """
2297 // 'window' is not in scope because dart:html isn't imported.
2298 @MirrorsUsed(targets: 'window')
2299 import 'dart:mirrors';
2300
2301 main() {}
2302 """
2303 ],
2304 },
2305
2306 'MIRRORS_CANNOT_RESOLVE_IN_LIBRARY': {
2307 'id': 'RUEKXE',
2308 'template': "Can't find '#{name}' in the library '#{library}'.",
2309 // TODO(ahe): The closest identifiers in edit distance would be nice.
2310 'howToFix': "Is '#{name}' spelled right?",
2311 'examples': [
2312 """
2313 // 'List' is misspelled.
2314 @MirrorsUsed(targets: 'dart.core.Lsit')
2315 import 'dart:mirrors';
2316
2317 main() {}
2318 """
2319 ],
2320 },
2321
2322 'MIRRORS_CANNOT_FIND_IN_ELEMENT': {
2323 'id': 'ACPDCS',
2324 'template': "Can't find '#{name}' in '#{element}'.",
2325 // TODO(ahe): The closest identifiers in edit distance would be nice.
2326 'howToFix': "Is '#{name}' spelled right?",
2327 'examples': [
2328 """
2329 // 'addAll' is misspelled.
2330 @MirrorsUsed(targets: 'dart.core.List.addAl')
2331 import 'dart:mirrors';
2332
2333 main() {}
2334 """
2335 ],
2336 },
2337
2338 'INVALID_URI': {
2339 'id': 'QQEQMK',
2340 'template': "'#{uri}' is not a valid URI.",
2341 'howToFix': DONT_KNOW_HOW_TO_FIX,
2342 'examples': [
2343 """
2344 // can't have a '[' in a URI
2345 import '../../Udyn[mic ils/expect.dart';
2346
2347 main() {}
2348 """
2349 ],
2350 },
2351
2352 'INVALID_PACKAGE_CONFIG': {
2353 'id': 'XKFAJO',
2354 'template': """Package config file '#{uri}' is invalid.
2355 #{exception}""",
2356 'howToFix': DONT_KNOW_HOW_TO_FIX
2357 },
2358
2359 'INVALID_PACKAGE_URI': {
2360 'id': 'MFVNNJ',
2361 'template': "'#{uri}' is not a valid package URI (#{exception}).",
2362 'howToFix': DONT_KNOW_HOW_TO_FIX,
2363 'examples': [
2364 """
2365 // can't have a 'top level' package URI
2366 import 'package:foo.dart';
2367
2368 main() {}
2369 """,
2370 """
2371 // can't have 2 slashes
2372 import 'package://foo/foo.dart';
2373
2374 main() {}
2375 """,
2376 """
2377 // package name must be valid
2378 import 'package:not\valid/foo.dart';
2379
2380 main() {}
2381 """
2382 ],
2383 },
2384
2385 'READ_SCRIPT_ERROR': {
2386 'id': 'JDDYLH',
2387 'template': "Can't read '#{uri}' (#{exception}).",
2388 // Don't know how to fix since the underlying error is unknown.
2389 'howToFix': DONT_KNOW_HOW_TO_FIX,
2390 'examples': [
2391 """
2392 // 'foo.dart' does not exist.
2393 import 'foo.dart';
2394
2395 main() {}
2396 """
2397 ],
2398 },
2399
2400 'READ_SELF_ERROR': {
2401 'id': 'CRJUAV',
2402 'template': "#{exception}",
2403 // Don't know how to fix since the underlying error is unknown.
2404 'howToFix': DONT_KNOW_HOW_TO_FIX
2405 },
2406
2407 'EXTRANEOUS_MODIFIER': {
2408 'id': 'DPLVJG',
2409 'template': "Can't have modifier '#{modifier}' here.",
2410 'howToFix': "Try removing '#{modifier}'.",
2411 'examples': [
2412 "var String foo; main(){}",
2413 // "var get foo; main(){}",
2414 "var set foo; main(){}",
2415 "var final foo; main(){}",
2416 "var var foo; main(){}",
2417 "var const foo; main(){}",
2418 "var abstract foo; main(){}",
2419 "var static foo; main(){}",
2420 "var external foo; main(){}",
2421 "get var foo; main(){}",
2422 "set var foo; main(){}",
2423 "final var foo; main(){}",
2424 "var var foo; main(){}",
2425 "const var foo; main(){}",
2426 "abstract var foo; main(){}",
2427 "static var foo; main(){}",
2428 "external var foo; main(){}"
2429 ],
2430 },
2431
2432 'EXTRANEOUS_MODIFIER_REPLACE': {
2433 'id': 'SSXDLN',
2434 'template': "Can't have modifier '#{modifier}' here.",
2435 'howToFix': "Try replacing modifier '#{modifier}' with 'var', 'final', "
2436 "or a type.",
2437 'examples': [
2438 // "get foo; main(){}",
2439 "set foo; main(){}",
2440 "abstract foo; main(){}",
2441 "static foo; main(){}",
2442 "external foo; main(){}"
2443 ],
2444 },
2445
2446 'ABSTRACT_CLASS_INSTANTIATION': {
2447 'id': 'KOBCRO',
2448 'template': "Can't instantiate abstract class.",
2449 'howToFix': DONT_KNOW_HOW_TO_FIX,
2450 'examples': ["abstract class A {} main() { new A(); }"],
2451 },
2452
2453 'BODY_EXPECTED': {
2454 'id': 'YXCAHO',
2455 'template': "Expected a function body or '=>'.",
2456 // TODO(ahe): In some scenarios, we can suggest removing the 'static'
2457 // keyword.
2458 'howToFix': "Try adding {}.",
2459 'examples': ["main();"],
2460 },
2461
2462 'MIRROR_BLOAT': {
2463 'id': 'BSEAIT',
2464 'template':
2465 "#{count} methods retained for use by dart:mirrors out of #{total}"
2466 " total methods (#{percentage}%).",
2467 },
2468
2469 'MIRROR_IMPORT': {'id': 'BDAETE', 'template': "Import of 'dart:mirrors'.",},
2470
2471 'MIRROR_IMPORT_NO_USAGE': {
2472 'id': 'OJOHTR',
2473 'template':
2474 "This import is not annotated with @MirrorsUsed, which may lead to "
2475 "unnecessarily large generated code.",
2476 'howToFix': "Try adding '@MirrorsUsed(...)' as described at "
2477 "https://goo.gl/Akrrog.",
2478 },
2479
2480 'JS_PLACEHOLDER_CAPTURE': {
2481 'id': 'EJXEGQ',
2482 'template': "JS code must not use '#' placeholders inside functions.",
2483 'howToFix': "Use an immediately called JavaScript function to capture the"
2484 " the placeholder values as JavaScript function parameters.",
2485 },
2486
2487 'WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT': {
2488 'id': 'JHRISO',
2489 'template':
2490 "Argument for 'JS_INTERCEPTOR_CONSTANT' must be a type constant.",
2491 },
2492
2493 'EXPECTED_IDENTIFIER_NOT_RESERVED_WORD': {
2494 'id': 'FEJXJF',
2495 'template': "'#{keyword}' is a reserved word and can't be used here.",
2496 'howToFix': "Try using a different name.",
2497 'examples': ["do() {} main() {}"],
2498 },
2499
2500 'NAMED_FUNCTION_EXPRESSION': {
2501 'id': 'CTHFPI',
2502 'template': "Function expression '#{name}' cannot be named.",
2503 'howToFix': "Try removing the name.",
2504 'examples': ["main() { var f = func() {}; }"],
2505 },
2506
2507 'UNUSED_METHOD': {
2508 'id': 'PKLRQL',
2509 'template': "The method '#{name}' is never called.",
2510 'howToFix': "Consider deleting it.",
2511 'examples': ["deadCode() {} main() {}"],
2512 },
2513
2514 'UNUSED_CLASS': {
2515 'id': 'TBIECC',
2516 'template': "The class '#{name}' is never used.",
2517 'howToFix': "Consider deleting it.",
2518 'examples': ["class DeadCode {} main() {}"],
2519 },
2520
2521 'UNUSED_TYPEDEF': {
2522 'id': 'JBIPCN',
2523 'template': "The typedef '#{name}' is never used.",
2524 'howToFix': "Consider deleting it.",
2525 'examples': ["typedef DeadCode(); main() {}"],
2526 },
2527
2528 'ABSTRACT_METHOD': {
2529 'id': 'HOKOBG',
2530 'template': "The method '#{name}' has no implementation in "
2531 "class '#{class}'.",
2532 'howToFix': "Try adding a body to '#{name}' or declaring "
2533 "'#{class}' to be 'abstract'.",
2534 'examples': [
2535 """
2536 class Class {
2537 method();
2538 }
2539 main() => new Class().method();
2540 """
2541 ],
2542 },
2543
2544 'ABSTRACT_GETTER': {
2545 'id': 'VKTRNK',
2546 'template': "The getter '#{name}' has no implementation in "
2547 "class '#{class}'.",
2548 'howToFix': "Try adding a body to '#{name}' or declaring "
2549 "'#{class}' to be 'abstract'.",
2550 'examples': [
2551 """
2552 class Class {
2553 get getter;
2554 }
2555 main() => new Class();
2556 """
2557 ],
2558 },
2559
2560 'ABSTRACT_SETTER': {
2561 'id': 'XGDGKK',
2562 'template': "The setter '#{name}' has no implementation in "
2563 "class '#{class}'.",
2564 'howToFix': "Try adding a body to '#{name}' or declaring "
2565 "'#{class}' to be 'abstract'.",
2566 'examples': [
2567 """
2568 class Class {
2569 set setter(_);
2570 }
2571 main() => new Class();
2572 """
2573 ],
2574 },
2575
2576 'INHERIT_GETTER_AND_METHOD': {
2577 'id': 'UMEUEG',
2578 'template': "The class '#{class}' can't inherit both getters and methods "
2579 "by the named '#{name}'.",
2580 'howToFix': DONT_KNOW_HOW_TO_FIX,
2581 'examples': [
2582 """
2583 class A {
2584 get member => null;
2585 }
2586 class B {
2587 member() {}
2588 }
2589 class Class implements A, B {
2590 }
2591 main() => new Class();
2592 """
2593 ],
2594 },
2595
2596 'INHERITED_METHOD': {
2597 'id': 'GMSVBM',
2598 'template': "The inherited method '#{name}' is declared here in class "
2599 "'#{class}'.",
2600 },
2601
2602 'INHERITED_EXPLICIT_GETTER': {
2603 'id': 'KKAVRS',
2604 'template': "The inherited getter '#{name}' is declared here in class "
2605 "'#{class}'.",
2606 },
2607
2608 'INHERITED_IMPLICIT_GETTER': {
2609 'id': 'JBAMEJ',
2610 'template': "The inherited getter '#{name}' is implicitly declared by this "
2611 "field in class '#{class}'.",
2612 },
2613
2614 'UNIMPLEMENTED_METHOD_ONE': {
2615 'id': 'CMCLWO',
2616 'template': "'#{class}' doesn't implement '#{method}' "
2617 "declared in '#{declarer}'.",
2618 'howToFix': "Try adding an implementation of '#{name}' or declaring "
2619 "'#{class}' to be 'abstract'.",
2620 'examples': [
2621 """
2622 abstract class I {
2623 m();
2624 }
2625 class C implements I {}
2626 main() => new C();
2627 """,
2628 """
2629 abstract class I {
2630 m();
2631 }
2632 class C extends I {}
2633 main() => new C();
2634 """
2635 ],
2636 },
2637
2638 'UNIMPLEMENTED_METHOD': {
2639 'id': 'IJSNQB',
2640 'template': "'#{class}' doesn't implement '#{method}'.",
2641 'howToFix': "Try adding an implementation of '#{name}' or declaring "
2642 "'#{class}' to be 'abstract'.",
2643 'examples': [
2644 """
2645 abstract class I {
2646 m();
2647 }
2648
2649 abstract class J {
2650 m();
2651 }
2652
2653 class C implements I, J {}
2654
2655 main() {
2656 new C();
2657 }
2658 """,
2659 """
2660 abstract class I {
2661 m();
2662 }
2663
2664 abstract class J {
2665 m();
2666 }
2667
2668 class C extends I implements J {}
2669
2670 main() {
2671 new C();
2672 }
2673 """
2674 ],
2675 },
2676
2677 'UNIMPLEMENTED_METHOD_CONT': {
2678 'id': 'KFBKPO',
2679 'template': "The method '#{name}' is declared here in class '#{class}'.",
2680 },
2681
2682 'UNIMPLEMENTED_SETTER_ONE': {
2683 'id': 'QGKTEA',
2684 'template': "'#{class}' doesn't implement the setter '#{name}' "
2685 "declared in '#{declarer}'.",
2686 'howToFix': "Try adding an implementation of '#{name}' or declaring "
2687 "'#{class}' to be 'abstract'.",
2688 'examples': [
2689 """
2690 abstract class I {
2691 set m(_);
2692 }
2693 class C implements I {}
2694 class D implements I {
2695 set m(_) {}
2696 }
2697 main() {
2698 new D().m = 0;
2699 new C();
2700 }
2701 """
2702 ],
2703 },
2704
2705 'UNIMPLEMENTED_SETTER': {
2706 'id': 'VEEGJQ',
2707 'template': "'#{class}' doesn't implement the setter '#{name}'.",
2708 'howToFix': "Try adding an implementation of '#{name}' or declaring "
2709 "'#{class}' to be 'abstract'.",
2710 'examples': [
2711 """
2712 abstract class I {
2713 set m(_);
2714 }
2715 abstract class J {
2716 set m(_);
2717 }
2718 class C implements I, J {}
2719 main() => new C();
2720 """,
2721 """
2722 abstract class I {
2723 set m(_);
2724 }
2725 abstract class J {
2726 set m(_);
2727 }
2728 class C extends I implements J {}
2729 main() => new C();
2730 """
2731 ],
2732 },
2733
2734 'UNIMPLEMENTED_EXPLICIT_SETTER': {
2735 'id': 'SABABA',
2736 'template': "The setter '#{name}' is declared here in class '#{class}'.",
2737 },
2738
2739 'UNIMPLEMENTED_IMPLICIT_SETTER': {
2740 'id': 'SWESAQ',
2741 'template': "The setter '#{name}' is implicitly declared by this field "
2742 "in class '#{class}'.",
2743 },
2744
2745 'UNIMPLEMENTED_GETTER_ONE': {
2746 'id': 'ODEPFW',
2747 'template': "'#{class}' doesn't implement the getter '#{name}' "
2748 "declared in '#{declarer}'.",
2749 'howToFix': "Try adding an implementation of '#{name}' or declaring "
2750 "'#{class}' to be 'abstract'.",
2751 'examples': [
2752 """
2753 abstract class I {
2754 get m;
2755 }
2756 class C implements I {}
2757 main() => new C();
2758 """,
2759 """
2760 abstract class I {
2761 get m;
2762 }
2763 class C extends I {}
2764 main() => new C();
2765 """
2766 ],
2767 },
2768
2769 'UNIMPLEMENTED_GETTER': {
2770 'id': 'VHSECG',
2771 'template': "'#{class}' doesn't implement the getter '#{name}'.",
2772 'howToFix': "Try adding an implementation of '#{name}' or declaring "
2773 "'#{class}' to be 'abstract'.",
2774 'examples': [
2775 """
2776 abstract class I {
2777 get m;
2778 }
2779 abstract class J {
2780 get m;
2781 }
2782 class C implements I, J {}
2783 main() => new C();
2784 """,
2785 """
2786 abstract class I {
2787 get m;
2788 }
2789 abstract class J {
2790 get m;
2791 }
2792 class C extends I implements J {}
2793 main() => new C();
2794 """
2795 ],
2796 },
2797
2798 'UNIMPLEMENTED_EXPLICIT_GETTER': {
2799 'id': 'HFDJPP',
2800 'template': "The getter '#{name}' is declared here in class '#{class}'.",
2801 },
2802
2803 'UNIMPLEMENTED_IMPLICIT_GETTER': {
2804 'id': 'BSCQNO',
2805 'template': "The getter '#{name}' is implicitly declared by this field "
2806 "in class '#{class}'.",
2807 },
2808
2809 'EQUAL_MAP_ENTRY_KEY': {
2810 'id': 'KIDLPM',
2811 'template': "An entry with the same key already exists in the map.",
2812 'howToFix': "Try removing the previous entry or changing the key in one "
2813 "of the entries.",
2814 'examples': [
2815 """
2816 main() {
2817 var m = const {'foo': 1, 'foo': 2};
2818 }"""
2819 ],
2820 },
2821
2822 'BAD_INPUT_CHARACTER': {
2823 'id': 'SHQWJY',
2824 'template': "Character U+#{characterHex} isn't allowed here.",
2825 'howToFix': DONT_KNOW_HOW_TO_FIX,
2826 'examples': [
2827 """
2828 main() {
2829 String x = ç;
2830 }
2831 """
2832 ],
2833 },
2834
2835 'UNTERMINATED_STRING': {
2836 'id': 'TRLTHK',
2837 'template': "String must end with #{quote}.",
2838 'howToFix': DONT_KNOW_HOW_TO_FIX,
2839 'examples': [
2840 """
2841 main() {
2842 return '
2843 ;
2844 }
2845 """,
2846 """
2847 main() {
2848 return \"
2849 ;
2850 }
2851 """,
2852 """
2853 main() {
2854 return r'
2855 ;
2856 }
2857 """,
2858 """
2859 main() {
2860 return r\"
2861 ;
2862 }
2863 """,
2864 """
2865 main() => '''
2866 """,
2867 """
2868 main() => \"\"\"
2869 """,
2870 """
2871 main() => r'''
2872 """,
2873 """
2874 main() => r\"\"\"
2875 """
2876 ],
2877 },
2878
2879 'UNMATCHED_TOKEN': {
2880 'id': 'AGJKMQ',
2881 'template': "Can't find '#{end}' to match '#{begin}'.",
2882 'howToFix': DONT_KNOW_HOW_TO_FIX,
2883 'examples': ["main(", "main(){", "main(){]}",],
2884 },
2885
2886 'UNTERMINATED_TOKEN': {
2887 'id': 'VIIXHQ',
2888 'template':
2889 // This is a fall-back message that shouldn't happen.
2890 "Incomplete token.",
2891 },
2892
2893 'EXPONENT_MISSING': {
2894 'id': 'CXPLCR',
2895 'template':
2896 "Numbers in exponential notation should always contain an exponent"
2897 " (an integer number with an optional sign).",
2898 'howToFix': "Make sure there is an exponent, and remove any whitespace "
2899 "before it.",
2900 'examples': [
2901 """
2902 main() {
2903 var i = 1e;
2904 }
2905 """
2906 ],
2907 },
2908
2909 'HEX_DIGIT_EXPECTED': {
2910 'id': 'GKCAGV',
2911 'template': "A hex digit (0-9 or A-F) must follow '0x'.",
2912 'howToFix': DONT_KNOW_HOW_TO_FIX, // Seems obvious from the error message.
2913 'examples': [
2914 """
2915 main() {
2916 var i = 0x;
2917 }
2918 """
2919 ],
2920 },
2921
2922 'MALFORMED_STRING_LITERAL': {
2923 'id': 'DULNSD',
2924 'template':
2925 r"A '$' has special meaning inside a string, and must be followed by "
2926 "an identifier or an expression in curly braces ({}).",
2927 'howToFix': r"Try adding a backslash (\) to escape the '$'.",
2928 'examples': [
2929 r"""
2930 main() {
2931 return '$';
2932 }
2933 """,
2934 r'''
2935 main() {
2936 return "$";
2937 }
2938 ''',
2939 r"""
2940 main() {
2941 return '''$''';
2942 }
2943 """,
2944 r'''
2945 main() {
2946 return """$""";
2947 }
2948 '''
2949 ],
2950 },
2951
2952 'UNTERMINATED_COMMENT': {
2953 'id': 'NECJNM',
2954 'template': "Comment starting with '/*' must end with '*/'.",
2955 'howToFix': DONT_KNOW_HOW_TO_FIX,
2956 'examples': [
2957 r"""
2958 main() {
2959 }
2960 /*"""
2961 ],
2962 },
2963
2964 'MISSING_TOKEN_BEFORE_THIS': {
2965 'id': 'AFKXGU',
2966 'template': "Expected '#{token}' before this.",
2967 // Consider the second example below: the parser expects a ')' before
2968 // 'y', but a ',' would also have worked. We don't have enough
2969 // information to give a good suggestion.
2970 'howToFix': DONT_KNOW_HOW_TO_FIX,
2971 'examples': ["main() => true ? 1;", "main() => foo(x: 1 y: 2);",],
2972 },
2973
2974 'MISSING_TOKEN_AFTER_THIS': {
2975 'id': 'FMUFJL',
2976 'template': "Expected '#{token}' after this.",
2977 // See [MISSING_TOKEN_BEFORE_THIS], we don't have enough information
2978 // to give a good suggestion.
2979 'howToFix': DONT_KNOW_HOW_TO_FIX,
2980 'examples': [
2981 "main(x) {x}",
2982 """
2983 class S1 {}
2984 class S2 {}
2985 class S3 {}
2986 class A = S1 with S2, S3
2987 main() => new A();
2988 """
2989 ],
2990 },
2991
2992 'CONSIDER_ANALYZE_ALL': {
2993 'id': 'HHILSH',
2994 'template': "Could not find '#{main}'. Nothing will be analyzed.",
2995 'howToFix': "Try using '--analyze-all' to analyze everything.",
2996 'examples': [''],
2997 },
2998
2999 'MISSING_MAIN': {
3000 'id': 'HNAOPV',
3001 'template': "Could not find '#{main}'.",
3002 // No example, test uses '--analyze-only' which will produce the above
3003 // message [CONSIDER_ANALYZE_ALL]. An example for a human operator
3004 // would be an empty file.
3005 'howToFix': "Try adding a method named '#{main}' to your program."
3006 },
3007
3008 'MAIN_NOT_A_FUNCTION': {
3009 'id': 'PIURPA',
3010 'template': "'#{main}' is not a function.",
3011 'howToFix': DONT_KNOW_HOW_TO_FIX, // Don't state the obvious.
3012 'examples': ['var main;'],
3013 },
3014
3015 'MAIN_WITH_EXTRA_PARAMETER': {
3016 'id': 'ONOGQB',
3017 'template': "'#{main}' cannot have more than two parameters.",
3018 'howToFix': DONT_KNOW_HOW_TO_FIX, // Don't state the obvious.
3019 'examples': ['main(a, b, c) {}'],
3020 },
3021
3022 'COMPILER_CRASHED': {
3023 'id': 'MHDWAV',
3024 'template': "The compiler crashed when compiling this element.",
3025 },
3026
3027 'PLEASE_REPORT_THE_CRASH': {
3028 'id': 'UUTHXX',
3029 'template': '''
3030 The compiler is broken.
3031
3032 When compiling the above element, the compiler crashed. It is not
3033 possible to tell if this is caused by a problem in your program or
3034 not. Regardless, the compiler should not crash.
3035
3036 The Dart team would greatly appreciate if you would take a moment to
3037 report this problem at http://dartbug.com/new.
3038
3039 Please include the following information:
3040
3041 * the name and version of your operating system,
3042
3043 * the Dart SDK build number (#{buildId}), and
3044
3045 * the entire message you see here (including the full stack trace
3046 below as well as the source location above).
3047 ''',
3048 },
3049
3050 'POTENTIAL_MUTATION': {
3051 'id': 'YGNLLB',
3052 'template': "Variable '#{variableName}' is not known to be of type "
3053 "'#{shownType}' because it is potentially mutated in the scope for "
3054 "promotion.",
3055 },
3056
3057 'POTENTIAL_MUTATION_HERE': {
3058 'id': 'ATMSVX',
3059 'template': "Variable '#{variableName}' is potentially mutated here.",
3060 },
3061
3062 'POTENTIAL_MUTATION_IN_CLOSURE': {
3063 'id': 'XUAHTW',
3064 'template': "Variable '#{variableName}' is not known to be of type "
3065 "'#{shownType}' because it is potentially mutated within a closure.",
3066 },
3067
3068 'POTENTIAL_MUTATION_IN_CLOSURE_HERE': {
3069 'id': 'UHFXLG',
3070 'template': "Variable '#{variableName}' is potentially mutated in a "
3071 "closure here.",
3072 },
3073
3074 'ACCESSED_IN_CLOSURE': {
3075 'id': 'JJHKSF',
3076 'template': "Variable '#{variableName}' is not known to be of type "
3077 "'#{shownType}' because it is accessed by a closure in the scope for "
3078 "promotion and potentially mutated in the scope of "
3079 "'#{variableName}'.",
3080 },
3081
3082 'ACCESSED_IN_CLOSURE_HERE': {
3083 'id': 'KMJVEA',
3084 'template': "Variable '#{variableName}' is accessed in a closure here.",
3085 },
3086
3087 'NOT_MORE_SPECIFIC': {
3088 'id': 'EJHQAG',
3089 'template': "Variable '#{variableName}' is not shown to have type "
3090 "'#{shownType}' because '#{shownType}' is not more specific than the "
3091 "known type '#{knownType}' of '#{variableName}'.",
3092 },
3093
3094 'NOT_MORE_SPECIFIC_SUBTYPE': {
3095 'id': 'APICDL',
3096 'template': "Variable '#{variableName}' is not shown to have type "
3097 "'#{shownType}' because '#{shownType}' is not a subtype of the "
3098 "known type '#{knownType}' of '#{variableName}'.",
3099 },
3100
3101 'NOT_MORE_SPECIFIC_SUGGESTION': {
3102 'id': 'FFNCJX',
3103 'template': "Variable '#{variableName}' is not shown to have type "
3104 "'#{shownType}' because '#{shownType}' is not more specific than the "
3105 "known type '#{knownType}' of '#{variableName}'.",
3106 'howToFix': "Try replacing '#{shownType}' with '#{shownTypeSuggestion}'.",
3107 },
3108
3109 'NO_COMMON_SUBTYPES': {
3110 'id': 'XKJOEC',
3111 'template': "Types '#{left}' and '#{right}' have no common subtypes.",
3112 },
3113
3114 'HIDDEN_WARNINGS_HINTS': {
3115 'id': 'JBAWEK',
3116 'template':
3117 "#{warnings} warning(s) and #{hints} hint(s) suppressed in #{uri}.",
3118 },
3119
3120 'HIDDEN_WARNINGS': {
3121 'id': 'JIYWDC',
3122 'template': "#{warnings} warning(s) suppressed in #{uri}.",
3123 },
3124
3125 'HIDDEN_HINTS': {
3126 'id': 'RHNXQT',
3127 'template': "#{hints} hint(s) suppressed in #{uri}.",
3128 },
3129
3130 'PREAMBLE': {
3131 'id': 'GXGWIF',
3132 'template': "When run on the command-line, the compiled output might"
3133 " require a preamble file located in:\n"
3134 " <sdk>/lib/_internal/js_runtime/lib/preambles.",
3135 },
3136
3137 'INVALID_SYNC_MODIFIER': {
3138 'id': 'FNYUYU',
3139 'template': "Invalid modifier 'sync'.",
3140 'options': ['--enable-async'],
3141 'howToFix': "Try replacing 'sync' with 'sync*'.",
3142 'examples': ["main() sync {}"],
3143 },
3144
3145 'INVALID_AWAIT_FOR': {
3146 'id': 'IEYGCY',
3147 'template': "'await' is only supported on for-in loops.",
3148 'options': ['--enable-async'],
3149 'howToFix': "Try rewriting the loop as a for-in loop or removing the "
3150 "'await' keyword.",
3151 'examples': [
3152 """
3153 main() async* {
3154 await for (int i = 0; i < 10; i++) {}
3155 }
3156 """
3157 ],
3158 },
3159
3160 'ASYNC_MODIFIER_ON_ABSTRACT_METHOD': {
3161 'id': 'VRISLY',
3162 'template':
3163 "The modifier '#{modifier}' is not allowed on an abstract method.",
3164 'options': ['--enable-async'],
3165 'howToFix': "Try removing the '#{modifier}' modifier or adding a "
3166 "body to the method.",
3167 'examples': [
3168 """
3169 abstract class A {
3170 method() async;
3171 }
3172 class B extends A {
3173 method() {}
3174 }
3175 main() {
3176 A a = new B();
3177 a.method();
3178 }
3179 """
3180 ],
3181 },
3182
3183 'ASYNC_MODIFIER_ON_CONSTRUCTOR': {
3184 'id': 'DHCFON',
3185 'template': "The modifier '#{modifier}' is not allowed on constructors.",
3186 'options': ['--enable-async'],
3187 'howToFix': "Try removing the '#{modifier}' modifier.",
3188 'examples': [
3189 """
3190 class A {
3191 A() async;
3192 }
3193 main() => new A();""",
3194 """
3195 class A {
3196 A();
3197 factory A.a() async* {}
3198 }
3199 main() => new A.a();"""
3200 ],
3201 },
3202
3203 'ASYNC_MODIFIER_ON_SETTER': {
3204 'id': 'NMJLJE',
3205 'template': "The modifier '#{modifier}' is not allowed on setters.",
3206 'options': ['--enable-async'],
3207 'howToFix': "Try removing the '#{modifier}' modifier.",
3208 'examples': [
3209 """
3210 class A {
3211 set foo(v) async {}
3212 }
3213 main() => new A().foo = 0;"""
3214 ],
3215 },
3216
3217 'YIELDING_MODIFIER_ON_ARROW_BODY': {
3218 'id': 'UOGLUX',
3219 'template':
3220 "The modifier '#{modifier}' is not allowed on methods implemented "
3221 "using '=>'.",
3222 'options': ['--enable-async'],
3223 'howToFix': "Try removing the '#{modifier}' modifier or implementing "
3224 "the method body using a block: '{ ... }'.",
3225 'examples': ["main() sync* => null;", "main() async* => null;"],
3226 },
3227
3228 // TODO(johnniwinther): Check for 'async' as identifier.
3229 'ASYNC_KEYWORD_AS_IDENTIFIER': {
3230 'id': 'VTWSMA',
3231 'template':
3232 "'#{keyword}' cannot be used as an identifier in a function body "
3233 "marked with '#{modifier}'.",
3234 'options': ['--enable-async'],
3235 'howToFix': "Try removing the '#{modifier}' modifier or renaming the "
3236 "identifier.",
3237 'examples': [
3238 """
3239 main() async {
3240 var await;
3241 }""",
3242 """
3243 main() async* {
3244 var yield;
3245 }""",
3246 """
3247 main() sync* {
3248 var yield;
3249 }"""
3250 ],
3251 },
3252
3253 'RETURN_IN_GENERATOR': {
3254 'id': 'AWGUVF',
3255 'template':
3256 "'return' with a value is not allowed in a method body using the "
3257 "'#{modifier}' modifier.",
3258 'howToFix': "Try removing the value, replacing 'return' with 'yield' "
3259 "or changing the method body modifier.",
3260 'examples': [
3261 """
3262 foo() async* { return 0; }
3263 main() => foo();
3264 """,
3265 """
3266 foo() sync* { return 0; }
3267 main() => foo();
3268 """
3269 ],
3270 },
3271
3272 'NATIVE_NOT_SUPPORTED': {
3273 'id': 'QMMLUT',
3274 'template': "'native' modifier is not supported.",
3275 'howToFix': "Try removing the 'native' implementation or analyzing the "
3276 "code with the --allow-native-extensions option.",
3277 'examples': [
3278 """
3279 main() native "Main";
3280 """
3281 ],
3282 },
3283
3284 'DART_EXT_NOT_SUPPORTED': {
3285 'id': 'JLPQFJ',
3286 'template': "The 'dart-ext' scheme is not supported.",
3287 'howToFix': "Try analyzing the code with the --allow-native-extensions "
3288 "option.",
3289 'examples': [
3290 """
3291 import 'dart-ext:main';
3292
3293 main() {}
3294 """
3295 ],
3296 },
3297
3298 'LIBRARY_TAG_MUST_BE_FIRST': {
3299 'id': 'JFUSRX',
3300 'template':
3301 "The library declaration should come before other declarations.",
3302 'howToFix': "Try moving the declaration to the top of the file.",
3303 'examples': [
3304 """
3305 import 'dart:core';
3306 library foo;
3307 main() {}
3308 """,
3309 ],
3310 },
3311
3312 'ONLY_ONE_LIBRARY_TAG': {
3313 'id': 'CCXFMY',
3314 'template': "There can only be one library declaration.",
3315 'howToFix': "Try removing all other library declarations.",
3316 'examples': [
3317 """
3318 library foo;
3319 library bar;
3320 main() {}
3321 """,
3322 """
3323 library foo;
3324 import 'dart:core';
3325 library bar;
3326 main() {}
3327 """,
3328 ],
3329 },
3330
3331 'IMPORT_BEFORE_PARTS': {
3332 'id': 'NSMOQI',
3333 'template': "Import declarations should come before parts.",
3334 'howToFix': "Try moving this import further up in the file.",
3335 'examples': [
3336 {
3337 'main.dart': """
3338 library test.main;
3339 part 'part.dart';
3340 import 'dart:core';
3341 main() {}
3342 """,
3343 'part.dart': """
3344 part of test.main;
3345 """,
3346 }
3347 ],
3348 },
3349
3350 'EXPORT_BEFORE_PARTS': {
3351 'id': 'KYJTTC',
3352 'template': "Export declarations should come before parts.",
3353 'howToFix': "Try moving this export further up in the file.",
3354 'examples': [
3355 {
3356 'main.dart': """
3357 library test.main;
3358 part 'part.dart';
3359 export 'dart:core';
3360 main() {}
3361 """,
3362 'part.dart': """
3363 part of test.main;
3364 """,
3365 }
3366 ],
3367
3368 //////////////////////////////////////////////////////////////////////////////
3369 // Patch errors start.
3370 //////////////////////////////////////////////////////////////////////////////
3371 },
3372
3373 'PATCH_RETURN_TYPE_MISMATCH': {
3374 'id': 'DTOQDU',
3375 'template': "Patch return type '#{patchReturnType}' does not match "
3376 "'#{originReturnType}' on origin method '#{methodName}'.",
3377 },
3378
3379 'PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH': {
3380 'id': 'KJUUYC',
3381 'template': "Required parameter count of patch method "
3382 "(#{patchParameterCount}) does not match parameter count on origin "
3383 "method '#{methodName}' (#{originParameterCount}).",
3384 },
3385
3386 'PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH': {
3387 'id': 'GUTGTE',
3388 'template': "Optional parameter count of patch method "
3389 "(#{patchParameterCount}) does not match parameter count on origin "
3390 "method '#{methodName}' (#{originParameterCount}).",
3391 },
3392
3393 'PATCH_OPTIONAL_PARAMETER_NAMED_MISMATCH': {
3394 'id': 'MCHEIC',
3395 'template': "Optional parameters of origin and patch method "
3396 "'#{methodName}' must both be either named or positional.",
3397 },
3398
3399 'PATCH_PARAMETER_MISMATCH': {
3400 'id': 'XISHPB',
3401 'template': "Patch method parameter '#{patchParameter}' does not match "
3402 "'#{originParameter}' on origin method '#{methodName}'.",
3403 },
3404
3405 'PATCH_PARAMETER_TYPE_MISMATCH': {
3406 'id': 'UGRBYD',
3407 'template': "Patch method parameter '#{parameterName}' type "
3408 "'#{patchParameterType}' does not match '#{originParameterType}' on "
3409 "origin method '#{methodName}'.",
3410 },
3411
3412 'PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION': {
3413 'id': 'WSNMKD',
3414 'template': "External method without an implementation.",
3415 },
3416
3417 'PATCH_POINT_TO_FUNCTION': {
3418 'id': 'CAVBPN',
3419 'template': "This is the function patch '#{functionName}'.",
3420 },
3421
3422 'PATCH_POINT_TO_CLASS': {
3423 'id': 'TWDLDX',
3424 'template': "This is the class patch '#{className}'.",
3425 },
3426
3427 'PATCH_POINT_TO_GETTER': {
3428 'id': 'TRBBNY',
3429 'template': "This is the getter patch '#{getterName}'.",
3430 },
3431
3432 'PATCH_POINT_TO_SETTER': {
3433 'id': 'DAXDLW',
3434 'template': "This is the setter patch '#{setterName}'.",
3435 },
3436
3437 'PATCH_POINT_TO_CONSTRUCTOR': {
3438 'id': 'VYQISY',
3439 'template': "This is the constructor patch '#{constructorName}'.",
3440 },
3441
3442 'PATCH_POINT_TO_PARAMETER': {
3443 'id': 'TFPAGO',
3444 'template': "This is the patch parameter '#{parameterName}'.",
3445 },
3446
3447 'PATCH_NON_EXISTING': {
3448 'id': 'AWOACF',
3449 'template': "Origin does not exist for patch '#{name}'.",
3450 },
3451
3452 // TODO(ahe): Eventually, this error should be removed as it will be
3453 // handled by the regular parser.
3454 'PATCH_NONPATCHABLE': {
3455 'id': 'WQEPJI',
3456 'template': "Only classes and functions can be patched.",
3457 },
3458
3459 'PATCH_NON_EXTERNAL': {
3460 'id': 'MHLXNK',
3461 'template': "Only external functions can be patched.",
3462 },
3463
3464 'PATCH_NON_CLASS': {
3465 'id': 'UIALAB',
3466 'template': "Patching non-class with class patch '#{className}'.",
3467 },
3468
3469 'PATCH_NON_GETTER': {
3470 'id': 'VTNQCJ',
3471 'template': "Cannot patch non-getter '#{name}' with getter patch.",
3472 },
3473
3474 'PATCH_NO_GETTER': {
3475 'id': 'XOPDHD',
3476 'template': "No getter found for getter patch '#{getterName}'.",
3477 },
3478
3479 'PATCH_NON_SETTER': {
3480 'id': 'XBOMMN',
3481 'template': "Cannot patch non-setter '#{name}' with setter patch.",
3482 },
3483
3484 'PATCH_NO_SETTER': {
3485 'id': 'YITARQ',
3486 'template': "No setter found for setter patch '#{setterName}'.",
3487 },
3488
3489 'PATCH_NON_CONSTRUCTOR': {
3490 'id': 'TWAEQV',
3491 'template': "Cannot patch non-constructor with constructor patch "
3492 "'#{constructorName}'.",
3493 },
3494
3495 'PATCH_NON_FUNCTION': {
3496 'id': 'EDXBPI',
3497 'template': "Cannot patch non-function with function patch "
3498 "'#{functionName}'.",
3499 },
3500
3501 'INJECTED_PUBLIC_MEMBER': {
3502 'id': 'JGMXMI',
3503 'template': "Non-patch members in patch libraries must be private.",
3504 },
3505
3506 'EXTERNAL_WITH_BODY': {
3507 'id': 'GAVMSQ',
3508 'template':
3509 "External function '#{functionName}' cannot have a function body.",
3510 'options': ["--output-type=dart"],
3511 'howToFix': "Try removing the 'external' modifier or the function body.",
3512 'examples': [
3513 """
3514 external foo() => 0;
3515 main() => foo();
3516 """,
3517 """
3518 external foo() {}
3519 main() => foo();
3520 """
3521 ],
3522
3523 //////////////////////////////////////////////////////////////////////////////
3524 // Patch errors end.
3525 //////////////////////////////////////////////////////////////////////////////
3526 },
3527
3528 'EXPERIMENTAL_ASSERT_MESSAGE': {
3529 'id': 'NENGIS',
3530 'template': "Experimental language feature 'assertion with message'"
3531 " is not supported.",
3532 'howToFix':
3533 "Use option '--assert-message' to use assertions with messages.",
3534 'examples': [
3535 r'''
3536 main() {
3537 int n = -7;
3538 assert(n > 0, 'must be positive: $n');
3539 }
3540 '''
3541 ],
3542 },
3543
3544 'IMPORT_EXPERIMENTAL_MIRRORS': {
3545 'id': 'SCJYPH',
3546 'template': '''
3547
3548 ****************************************************************
3549 * WARNING: dart:mirrors support in dart2js is experimental,
3550 * and not recommended.
3551 * This implementation of mirrors is incomplete,
3552 * and often greatly increases the size of the generated
3553 * JavaScript code.
3554 *
3555 * Your app imports dart:mirrors via:'''
3556 '''
3557 $IMPORT_EXPERIMENTAL_MIRRORS_PADDING#{importChain}
3558 *
3559 * You can disable this message by using the --enable-experimental-mirrors
3560 * command-line flag.
3561 *
3562 * To learn what to do next, please visit:
3563 * http://dartlang.org/dart2js-reflection
3564 ****************************************************************
3565 ''',
3566 },
3567
3568 'DISALLOWED_LIBRARY_IMPORT': {
3569 'id': 'OCSFJU',
3570 'template': '''
3571 Your app imports the unsupported library '#{uri}' via:
3572 '''
3573 '''
3574 $DISALLOWED_LIBRARY_IMPORT_PADDING#{importChain}
3575
3576 Use the --categories option to support import of '#{uri}'.
3577 ''',
3578 },
3579
3580 'MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND': {
3581 'id': 'JBTRRM',
3582 'template': """
3583 dart:mirrors library is not supported when using this backend.
3584
3585 Your app imports dart:mirrors via:"""
3586 """
3587 $MIRRORS_NOT_SUPPORTED_BY_BACKEND_PADDING#{importChain}""",
3588 },
3589
3590 'CALL_NOT_SUPPORTED_ON_NATIVE_CLASS': {
3591 'id': 'HAULDW',
3592 'template': "Non-supported 'call' member on a native class, or a "
3593 "subclass of a native class.",
3594 },
3595
3596 'DIRECTLY_THROWING_NSM': {
3597 'id': 'XLTPCS',
3598 'template': "This 'noSuchMethod' implementation is guaranteed to throw an "
3599 "exception. The generated code will be smaller if it is "
3600 "rewritten.",
3601 'howToFix': "Rewrite to "
3602 "'noSuchMethod(Invocation i) => super.noSuchMethod(i);'.",
3603 },
3604
3605 'COMPLEX_THROWING_NSM': {
3606 'id': 'PLCXVX',
3607 'template': "This 'noSuchMethod' implementation is guaranteed to throw an "
3608 "exception. The generated code will be smaller and the compiler "
3609 "will be able to perform more optimizations if it is rewritten.",
3610 'howToFix': "Rewrite to "
3611 "'noSuchMethod(Invocation i) => super.noSuchMethod(i);'.",
3612 },
3613
3614 'COMPLEX_RETURNING_NSM': {
3615 'id': 'HUTCTQ',
3616 'template': "Overriding 'noSuchMethod' causes the compiler to generate "
3617 "more code and prevents the compiler from doing some optimizations.",
3618 'howToFix': "Consider removing this 'noSuchMethod' implementation."
3619 },
3620
3621 'UNRECOGNIZED_VERSION_OF_LOOKUP_MAP': {
3622 'id': 'OVAFEW',
3623 'template': "Unsupported version of package:lookup_map.",
3624 'howToFix': DONT_KNOW_HOW_TO_FIX
3625 },
3626 };
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/diagnostics/messages.dart » ('j') | pkg/compiler/lib/src/diagnostics/messages.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698