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

Side by Side Diff: pkg/front_end/messages.yaml

Issue 2756923002: Diagnostic messages. (Closed)
Patch Set: Created 3 years, 9 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 map corresponds to a diagnostic message. Ideally, each
6 # entry contains three parts:
7 #
8 # 1. A message template (template).
9 #
10 # 2. A suggestion for how to correct the problem (tip).
11 #
12 # 3. Examples that produce the message (one of expression, statement,
13 # declaration, member, script, or bytes).
Siggi Cherem (dart-lang) 2017/03/17 21:48:34 do we want to also specify upfront the kind (error
ahe 2017/03/22 11:04:26 I like the idea of grouping messages. Some message
14 #
15 # ## Parameter Substitution in Template and Tip
16 #
17 # The fields `template` and `tip` are subject to parameter substitution. When
18 # the compiler reports a problem, it may also specify a map with the following
19 # keys to be substituted into the message:
20 #
21 # `#character` a Unicode character.
22 #
23 # `#unicode` a Unicode short identifier (U+xxxx). We use this to represent code
24 # units or code points.
25 #
26 # `#name` a name (a string).
27 #
28 # `#lexeme` a token. The token's `lexeme` property is used.
29 #
30 # `#string` a string.
31
32 AsciiControlCharacter:
33 template: "The control character #unicode can only be used in strings and comm ents."
34 expresssion: "\x1b 1"
35
36 NonAsciiIdentifier:
37 template: "The non-ASCII character '#character' (#unicode) can't be used in id entifiers, only in strings and comments."
38 tip: "Try using an US-ASCII letter, a digit, '_' (an underscore), or '$' (a do llar sign)."
39 expresssion: "å"
40
41 NonAsciiWhitespace:
42 template: "The non-ASCII space character #unicode can only be used in strings and comments."
43 expresssion: "\u2028 1"
44
45 Encoding:
46 template: "Unable to decode bytes as UTF-8."
47 bytes: [255]
48
49 EmptyNamedParameterList:
50 template: "Named parameter lists cannot be empty."
51 tip: "Try adding a named parameter to the list."
52 script: >
53 foo({}) {}
54
55 main() {
56 foo();
57 }
58
59 EmptyOptionalParameterList:
60 template: "Optional parameter lists cannot be empty."
61 tip: "Try adding an optional parameter to the list."
62 script: >
63 foo([]) {}
64
65 main() {
66 foo();
67 }
68
69 ExpectedBlockToSkip: ExpectedBody
70
71 ExpectedBody:
72 template: "Expected a function body or '=>'."
73 # TODO(ahe): In some scenarios, we can suggest removing the 'static' keyword.
74 tip: "Try adding {}."
75 script: "main();"
76
77 ExpectedButGot:
78 template: "Expected '#lexeme' before this."
79 # Consider the second example below: the parser expects a ')' before 'y', but
80 # a ',' would also have worked. We don't have enough information to give a
81 # good suggestion.
82 tip: DONT_KNOW_HOW_TO_FIX,
83 script:
84 - "main() => true ? 1;"
85 - "main() => foo(x: 1 y: 2);"
86
87 ExpectedClassBody:
88 template: "Expected a class body, but got '#lexeme'."
89
90 ExpectedClassBodyToSkip: ExpectedClassBody
91
92 ExpectedDeclaration:
93 template: "Expected a declaration, but got '#lexeme'."
94
95 ExpectedExpression:
96 template: "Expected an expression, but got '#lexeme'."
97
98 ExpectedFunctionBody:
99 template: "Expected a function body, but got '#lexeme'."
100
101 ExpectedHexDigit:
102 template: "A hex digit (0-9 or A-F) must follow '0x'."
103 # No tip, seems obvious from the error message.
104 script: >
105 main() {
106 var i = 0x;
107 }
108
109 ExpectedIdentifier:
110 template: "'#lexeme' is a reserved word and can't be used here."
111 tip: "Try using a different name."
112 script: "do() {} main() {}"
113
114 ExpectedOpenParens:
115 template: "Expected '('."
116
117 ExpectedString:
118 template: "Expected a String, but got '#lexeme'."
119
120 ExpectedType:
121 template: "Expected a type, but got '#lexeme'."
122
123 ExtraneousModifier:
124 template: "Can't have modifier '#lexeme' here."
125 tip: "Try removing '#lexeme'."
126 script:
127 - "var String foo; main(){}"
128 - "var set foo; main(){}"
129 - "var final foo; main(){}"
130 - "var var foo; main(){}"
131 - "var const foo; main(){}"
132 - "var abstract foo; main(){}"
133 - "var static foo; main(){}"
134 - "var external foo; main(){}"
135 - "get var foo; main(){}"
136 - "set var foo; main(){}"
137 - "final var foo; main(){}"
138 - "var var foo; main(){}"
139 - "const var foo; main(){}"
140 - "abstract var foo; main(){}"
141 - "static var foo; main(){}"
142 - "external var foo; main(){}"
143
144 ExtraneousModifierReplace:
145 template: "Can't have modifier '#lexeme' here."
146 tip: "Try replacing modifier '#lexeme' with 'var', 'final', or a type."
147 script:
148 - "set foo; main(){}"
149 - "abstract foo; main(){}"
150 - "static foo; main(){}"
151 - "external foo; main(){}"
152
153 InvalidAwaitFor:
154 template: "'await' is only supported in methods with an 'async' or 'async*' bo dy modifier."
155 tip: "Try adding 'async' or 'async*' to the method body or removing the 'await ' keyword."
156 script: >
157 main(o) sync* {
158 await for (var e in o) {}
159 }
160
161 InvalidSyncModifier:
162 template: "Invalid modifier 'sync'."
163 tip: "Try replacing 'sync' with 'sync*'."
164 script: "main() sync {}"
165
166 InvalidVoid:
167 template: "Type 'void' can't be used here because it isn't a return type."
168 tip: "Try removing 'void' keyword or replace it with 'var', 'final', or a type ."
169 script:
170 - "void x; main() {}"
171 - "foo(void x) {} main() { foo(null); }"
172
173 MissingExponent:
174 template: "Numbers in exponential notation should always contain an exponent ( an integer number with an optional sign)."
175 tip: "Make sure there is an exponent, and remove any whitespace before it."
176 script: >
177 main() {
178 var i = 1e;
179 }
180
181 PositionalParameterWithEquals:
182 template: "Positional optional parameters can't use ':' to specify a default v alue."
183 tip: "Try replacing ':' with '='."
184 script: >
185 main() {
186 foo([a: 1]) => print(a);
187 foo(2);
188 }
189
190 RequiredParameterWithDefault:
191 template: "Non-optional parameters can't have a default value."
192 tip: "Try removing the default value or making the parameter optional."
193 script:
194 - >
195 main() {
196 foo(a: 1) => print(a);
197 foo(2);
198 }
199 - >
200 main() {
201 foo(a = 1) => print(a);
202 foo(2);
203 }
204
205 StackOverflow:
206 template: "Stack overflow."
207
208 UnexpectedDollarInString:
209 template: "A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({})."
210 tip: "Try adding a backslash (\\) to escape the '$'."
211 script:
212 - >
213 main() {
214 return '$';
215 }
216 - >
217 main() {
218 return "$";
219 }
220 - >
221 main() {
222 return '''$''';
223 }
224 - >
225 main() {
226 return """$""";
227 }
228
229 UnexpectedToken:
230 template: "Unexpected token '#lexeme'."
231
232 UnmatchedToken:
233 template: "Can't find '#string' to match '#lexeme'."
234 script:
235 - "main("
236 - "main(){"
237 - "main(){[}"
238
239 UnsupportedPrefixPlus:
240 template: "'+' is not a prefix operator. "
241 tip: "Try removing '+'."
242 script: "main() => +2; // No longer a valid way to write '2'"
243
244 UnterminatedComment:
245 template: "Comment starting with '/*' must end with '*/'."
246 script:
247 main() {
248 }
249 /*
250
251 UnterminatedString:
252 template: "String must end with #string."
253 script:
254 - >
255 main() {
256 return '
257 ;
258 }
259 - >
260 main() {
261 return \"
262 ;
263 }
264 - >
265 main() {
266 return r'
267 ;
268 }
269 - >
270 main() {
271 return r\"
272 ;
273 }
274 - >
275 main() => '''
276 - >
277 main() => \"\"\"
278 - >
279 main() => r'''
280 - >
281 main() => r\"\"\"
282
283 UnterminatedToken:
284 # This is a fall-back message that shouldn't happen.
285 template: "Incomplete token."
286
287 Unspecified:
288 template: "#string"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698