Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright (c) 2017, 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 # Each entry in this file corresponds to an error recovery scenario. For each | |
| 6 # scenario we specify: | |
| 7 # | |
| 8 # 1. An explanation of the problem (description). | |
| 9 # 2. Important recovery notes (recovery): a list of text notes explaining of | |
| 10 # how the code is interpreted by the front-end and its clients. | |
| 11 # 3. An optional set of questions if we don't have the answer at this | |
| 12 # moment (questions). | |
| 13 # 4. An example code that illustrates the problem (example). | |
| 14 # | |
| 15 # At this time this is just a documentation file, the goal however is to turn it | |
| 16 # also into a test suite so every example can be tested automatically. | |
| 17 # | |
| 18 # To do so we can start annotating the examples to indicate relevant error | |
| 19 # locations with comments of the form `/*@error=name*/`, where `name` is a | |
|
scheglov
2017/08/10 00:13:14
Do we mark a line, a region, or a single identifie
Siggi Cherem (dart-lang)
2017/08/10 18:52:34
Good question: let's do a token or region dependin
| |
| 20 # message name from `messages.yaml` that corresponds to the error (if known). If | |
| 21 # the compiler doesn't yet have a specific error message for the error, use | |
| 22 # `/*@error=?*/`. | |
| 23 | |
| 24 NameConflictDuplicateField: | |
| 25 description: "A field was declared twice." | |
| 26 recovery: | |
| 27 - "both fields can be seen in the generated kernel output." | |
| 28 - "code completion works inside initializers of either field." | |
|
scheglov
2017/08/10 00:13:14
"inside initializers" seems limiting.
Why not in t
Siggi Cherem (dart-lang)
2017/08/10 18:52:34
Done.
| |
| 29 - "any errors from the usage of the field should be lower priority than this error." | |
| 30 questions: >- | |
| 31 How do we interpret accesses to the field value? Do we pick one of the | |
| 32 implementations? Treat it's type as Object? try to find an LUB for the type? | |
|
scheglov
2017/08/10 00:13:14
its
Try
Feel free to ignore this, if the goal is
Siggi Cherem (dart-lang)
2017/08/10 18:52:34
Sounds good. I adopted your suggestion.
| |
| 33 example: >- | |
| 34 List bar = [1, 2]; | |
| 35 StringBuffer foo = new StringBuffer(); | |
| 36 class A { | |
| 37 /*@error=DuplicatedName*/ int field = bar.length; | |
|
scheglov
2017/08/10 00:13:14
I think that the name of the field should be annot
Siggi Cherem (dart-lang)
2017/08/10 18:52:34
Done.
| |
| 38 /*@error=DuplicatedName*/ String field = '$foo'; | |
|
danrubel
2017/08/10 16:32:33
From an test automation standpoint, it would be re
Siggi Cherem (dart-lang)
2017/08/10 18:52:34
Good suggestion. Done. Added /*@errorEnd*/ for thi
| |
| 39 } | |
| 40 | |
| 41 NameConflictDuplicateMethod: | |
| 42 description: "A method was declared twice." | |
| 43 recovery: | |
| 44 - "both methods can be seen in the generated kernel output." | |
| 45 - "code completion works within both methods." | |
| 46 questions: >- | |
| 47 How do we interpret accesses to the methods? Do we pick one of the | |
| 48 implementations? Treat parameter and return types as Object? try to | |
| 49 find an LUB for the function type? | |
|
scheglov
2017/08/10 00:13:14
Same here - outside of the class only the first is
Siggi Cherem (dart-lang)
2017/08/10 18:52:34
Done.
| |
| 50 | |
| 51 example: >- | |
| 52 List bar = [1, 2]; | |
| 53 class A { | |
| 54 /*@error=DuplicatedName*/ | |
| 55 int m() => bar.length; | |
|
scheglov
2017/08/10 00:13:14
Same here - the problem is with the name, so the n
Siggi Cherem (dart-lang)
2017/08/10 18:52:34
Done.
| |
| 56 | |
| 57 /*@error=DuplicatedName*/ | |
| 58 int m(StringBuffer foo) => '$foo'; | |
| 59 } | |
| 60 | |
| 61 NameConflictInconsitentMemberKind: | |
| 62 description: "A method and a field have the same name." | |
| 63 recovery: | |
| 64 - "both can be seen in the generated output." | |
| 65 questions: >- | |
| 66 What do we do with accesses to this name? Pick one of the implementations? | |
| 67 Which one? Treat it as if it doesn't exist? Pick based on how it is used | |
| 68 (e.g. if it is used as a call, pick the method)? | |
| 69 | |
| 70 example: >- | |
| 71 List bar = [1, 2]; | |
| 72 class A { | |
| 73 /*@error=DuplicatedName*/ | |
| 74 int m() => bar.length; | |
| 75 | |
| 76 /*@error=DuplicatedName*/ | |
| 77 int m(StringBuffer foo) => '$foo'; | |
| 78 } | |
| 79 | |
| 80 ImportIsOutOfOrder: | |
| 81 description: "An import was written below a definition." | |
| 82 recovery: | |
| 83 - "treat it as if the import was on top" | |
| 84 - "lower priority on errors that cascade from this" | |
| 85 example: >- | |
| 86 class A extends /*@error=SupertypeIsIllegal*/ B {} | |
| 87 /*@error=?*/ | |
| 88 import 'b.dart'; // b.dart defines B | |
| 89 | |
| 90 CallAMissingConstructor: | |
| 91 description: "A named constructor has a typo in the name." | |
| 92 recovery: | |
| 93 - "keep the expression where it occurs." | |
| 94 - "treat the type of the expression as if a valid constructor was used." | |
| 95 example: >- | |
| 96 class C { | |
| 97 bar() => null; | |
| 98 } | |
| 99 main() { | |
| 100 var x = new C./*error=MethodNotFound*/foo(); | |
| 101 x.bar(); // no errors here, `x` has inferred type `C`. | |
| 102 } | |
| 103 | |
| 104 TreatAbstractFunctionsAsEmpty: | |
| 105 description: "A function in a non-abstract class is missing a body." | |
| 106 recovery: "Treat it as if it was empty." | |
| 107 example: >- | |
| 108 class A { | |
| 109 /*@error=ExpectedBody*/ | |
| 110 foo(); | |
| 111 } | |
| 112 | |
| 113 IgnoreEmptyOptionalArgs: | |
| 114 description: "A function declares optional argument, but the list is empty." | |
| 115 recovery: "Treat it as if it wasn't there." | |
| 116 example: >- | |
| 117 m(a, b, []){} | |
| 118 | |
| 119 IgnoreEmptyOptionalArgs: | |
| 120 description: "A function declares both positional and named arguments." | |
| 121 questions: "Treat it as if only named arguments are there?" | |
| 122 example: >- | |
| 123 m(a, b, [c], {d}){} | |
| 124 | |
| 125 # TODO(sigmund): add details to the list below | |
| 126 | |
| 127 NameConflictDuplicateTopLevelField: | |
| 128 description: "A top-level field was declared twice." | |
| 129 | |
| 130 NameConflictDuplicateTopLevelMethod: | |
| 131 description: "A top-level method was declared twice." | |
| 132 | |
| 133 NameConflictDuplicateTopLevelDeclaration: | |
| 134 description: "Two top-level declarations use the same name." | |
| OLD | NEW |