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 |
| 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=?*/`. This comment should go immediately before the token where the |
| 23 # error is reported. If we know at this time that the error has a region, |
| 24 # include an /*@errorEnd*/ at the point where the region ends. |
| 25 |
| 26 NameConflictDuplicateField: |
| 27 description: "A field was declared twice." |
| 28 recovery: |
| 29 - "both fields can be seen in the generated kernel output." |
| 30 - "code completion works on the types and inside initializers of either fiel
d." |
| 31 - "any errors from the usage of the field should be lower priority than this
error." |
| 32 - "accesses to the field get resolved to the first declaration (in text orde
r)." |
| 33 example: >- |
| 34 List bar = [1, 2]; |
| 35 StringBuffer foo = new StringBuffer(); |
| 36 class A { |
| 37 int /*@error=DuplicatedName*/ field /*@errorEnd*/ = bar.length; |
| 38 String /*@error=DuplicatedName*/ field /*@errorEnd*/ = '$foo'; |
| 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 - "other code that accesses the method will be resolved to the first declara
tion." |
| 47 example: >- |
| 48 List bar = [1, 2]; |
| 49 class A { |
| 50 int /*@error=DuplicatedName*/ m /*@errorEnd*/() => bar.length; |
| 51 int /*@error=DuplicatedName*/ m /*@errorEnd*/(StringBuffer foo) => '$foo'; |
| 52 } |
| 53 |
| 54 NameConflictInconsitentMemberKind: |
| 55 description: "A method and a field have the same name." |
| 56 recovery: |
| 57 - "both can be seen in the generated output." |
| 58 - "first declaration wins." |
| 59 example: >- |
| 60 List bar = [1, 2]; |
| 61 class A { |
| 62 int /*@error=DuplicatedName*/ m /*@errorEnd*/ = bar.length; |
| 63 int /*@error=DuplicatedName*/ m /*@errorEnd*/(StringBuffer foo) => '$foo'; |
| 64 } |
| 65 |
| 66 ImportIsOutOfOrder: |
| 67 description: "An import was written below a definition." |
| 68 recovery: |
| 69 - "treat it as if the import was on top." |
| 70 - "no cascading errors are presented as if the import was missing." |
| 71 example: >- |
| 72 class A extends B {} |
| 73 /*@error=?*/ |
| 74 import 'b.dart'; // b.dart defines B |
| 75 /*@errorEnd*/ |
| 76 |
| 77 CallAMissingConstructor: |
| 78 description: "A named constructor has a typo in the name." |
| 79 recovery: |
| 80 - "keep the expression where it occurs." |
| 81 - "treat the type of the expression as if a valid constructor was used." |
| 82 example: >- |
| 83 class C { |
| 84 bar() => null; |
| 85 } |
| 86 main() { |
| 87 var x = new C./*error=MethodNotFound*/foo(); |
| 88 x.bar(); // no errors here, `x` has inferred type `C`. |
| 89 } |
| 90 |
| 91 TreatAbstractFunctionsAsEmpty: |
| 92 description: "A function in a non-abstract class is missing a body." |
| 93 recovery: "Treat it as if it was empty." |
| 94 example: >- |
| 95 class A { |
| 96 foo() /*@error=ExpectedBody*/; |
| 97 } |
| 98 |
| 99 IgnoreEmptyOptionalArgs: |
| 100 description: "A function declares optional argument, but the list is empty." |
| 101 recovery: "Treat it as if it wasn't there." |
| 102 example: >- |
| 103 m(a, b, []){} |
| 104 |
| 105 IgnoreEmptyOptionalArgs: |
| 106 description: "A function declares both positional and named arguments." |
| 107 questions: "Treat it as if only named arguments are there?" |
| 108 example: >- |
| 109 m(a, b, [c], {d}){} |
| 110 |
| 111 # TODO(sigmund): add details to the list below |
| 112 |
| 113 NameConflictDuplicateTopLevelField: |
| 114 description: "A top-level field was declared twice." |
| 115 |
| 116 NameConflictDuplicateTopLevelMethod: |
| 117 description: "A top-level method was declared twice." |
| 118 |
| 119 NameConflictDuplicateTopLevelDeclaration: |
| 120 description: "Two top-level declarations use the same name." |
OLD | NEW |