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

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

Issue 2778213002: Use message.yaml in parser. (Closed)
Patch Set: Update subpackage relationships. Created 3 years, 8 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
OLDNEW
1 # Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 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 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. 3 # BSD-style license that can be found in the LICENSE file.
4 4
5 # Each entry in this map corresponds to a diagnostic message. Ideally, each 5 # Each entry in this map corresponds to a diagnostic message. Ideally, each
6 # entry contains three parts: 6 # entry contains three parts:
7 # 7 #
8 # 1. A message template (template). 8 # 1. A message template (template).
9 # 9 #
10 # 2. A suggestion for how to correct the problem (tip). 10 # 2. A suggestion for how to correct the problem (tip).
11 # 11 #
12 # 3. Examples that produce the message (one of expression, statement, 12 # 3. Examples that produce the message (one of expression, statement,
13 # declaration, member, script, or bytes). 13 # declaration, member, script, or bytes).
14 # 14 #
15 # In addition, an entry can contain an analyzer error code (analyzerCode) and a
16 # dart2js error code (dart2jsCode).
17 #
15 # ## Parameter Substitution in Template and Tip 18 # ## Parameter Substitution in Template and Tip
16 # 19 #
17 # The fields `template` and `tip` are subject to parameter substitution. When 20 # 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 21 # the compiler reports a problem, it may also specify a map with the following
19 # keys to be substituted into the message: 22 # keys to be substituted into the message:
20 # 23 #
21 # `#character` a Unicode character. 24 # `#character` a Unicode character.
22 # 25 #
23 # `#unicode` a Unicode short identifier (U+xxxx). We use this to represent code 26 # `#unicode` a Unicode short identifier (U+xxxx). We use this to represent code
24 # units or code points. 27 # units or code points.
25 # 28 #
26 # `#name` a name (a string). 29 # `#name` a name (a string).
27 # 30 #
28 # `#lexeme` a token. The token's `lexeme` property is used. 31 # `#lexeme` a token. The token's `lexeme` property is used.
29 # 32 #
30 # `#string` a string. 33 # `#string` a string.
31 34
32 AsciiControlCharacter: 35 AsciiControlCharacter:
33 template: "The control character #unicode can only be used in strings and comm ents." 36 template: "The control character #unicode can only be used in strings and comm ents."
37 dart2jsCode: BAD_INPUT_CHARACTER
34 expresssion: "\x1b 1" 38 expresssion: "\x1b 1"
35 39
36 NonAsciiIdentifier: 40 NonAsciiIdentifier:
37 template: "The non-ASCII character '#character' (#unicode) can't be used in id entifiers, only in strings and comments." 41 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)." 42 tip: "Try using an US-ASCII letter, a digit, '_' (an underscore), or '$' (a do llar sign)."
43 analyzerCode: ILLEGAL_CHARACTER
44 dart2jsCode: BAD_INPUT_CHARACTER
39 expresssion: "å" 45 expresssion: "å"
40 46
41 NonAsciiWhitespace: 47 NonAsciiWhitespace:
42 template: "The non-ASCII space character #unicode can only be used in strings and comments." 48 template: "The non-ASCII space character #unicode can only be used in strings and comments."
49 analyzerCode: ILLEGAL_CHARACTER
50 dart2jsCode: BAD_INPUT_CHARACTER
43 expresssion: "\u2028 1" 51 expresssion: "\u2028 1"
44 52
45 Encoding: 53 Encoding:
46 template: "Unable to decode bytes as UTF-8." 54 template: "Unable to decode bytes as UTF-8."
55 dart2jsCode: FASTA_FATAL
47 bytes: [255] 56 bytes: [255]
48 57
49 EmptyNamedParameterList: 58 EmptyNamedParameterList:
50 template: "Named parameter lists cannot be empty." 59 template: "Named parameter lists cannot be empty."
51 tip: "Try adding a named parameter to the list." 60 tip: "Try adding a named parameter to the list."
61 dart2jsCode: EMPTY_NAMED_PARAMETER_LIST
52 script: > 62 script: >
53 foo({}) {} 63 foo({}) {}
54 64
55 main() { 65 main() {
56 foo(); 66 foo();
57 } 67 }
58 68
59 EmptyOptionalParameterList: 69 EmptyOptionalParameterList:
60 template: "Optional parameter lists cannot be empty." 70 template: "Optional parameter lists cannot be empty."
61 tip: "Try adding an optional parameter to the list." 71 tip: "Try adding an optional parameter to the list."
72 dart2jsCode: EMPTY_OPTIONAL_PARAMETER_LIST
62 script: > 73 script: >
63 foo([]) {} 74 foo([]) {}
64 75
65 main() { 76 main() {
66 foo(); 77 foo();
67 } 78 }
68 79
69 ExpectedBlockToSkip: ExpectedBody 80 ExpectedBlockToSkip:
81 template: "Expected a function body or '=>'."
82 # TODO(ahe): In some scenarios, we can suggest removing the 'static' keyword.
83 tip: "Try adding {}."
84 dart2jsCode: NATIVE_OR_BODY_EXPECTED
85 script: "main();"
70 86
71 ExpectedBody: 87 ExpectedBody:
72 template: "Expected a function body or '=>'." 88 template: "Expected a function body or '=>'."
73 # TODO(ahe): In some scenarios, we can suggest removing the 'static' keyword. 89 # TODO(ahe): In some scenarios, we can suggest removing the 'static' keyword.
74 tip: "Try adding {}." 90 tip: "Try adding {}."
91 dart2jsCode: BODY_EXPECTED
75 script: "main();" 92 script: "main();"
76 93
77 ExpectedButGot: 94 ExpectedButGot:
78 template: "Expected '#lexeme' before this." 95 template: "Expected '#string' before this."
79 # Consider the second example below: the parser expects a ')' before 'y', but 96 # 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 97 # a ',' would also have worked. We don't have enough information to give a
81 # good suggestion. 98 # good suggestion.
82 tip: DONT_KNOW_HOW_TO_FIX, 99 tip: DONT_KNOW_HOW_TO_FIX,
100 dart2jsCode: MISSING_TOKEN_BEFORE_THIS
83 script: 101 script:
84 - "main() => true ? 1;" 102 - "main() => true ? 1;"
85 - "main() => foo(x: 1 y: 2);" 103 - "main() => foo(x: 1 y: 2);"
86 104
87 ExpectedClassBody: 105 ExpectedClassBody:
88 template: "Expected a class body, but got '#lexeme'." 106 template: "Expected a class body, but got '#lexeme'."
107 dart2jsCode: FASTA_FATAL
89 108
90 ExpectedClassBodyToSkip: ExpectedClassBody 109 ExpectedClassBodyToSkip: ExpectedClassBody
91 110
92 ExpectedDeclaration: 111 ExpectedDeclaration:
93 template: "Expected a declaration, but got '#lexeme'." 112 template: "Expected a declaration, but got '#lexeme'."
113 dart2jsCode: FASTA_FATAL
94 114
95 ExpectedExpression: 115 ExpectedExpression:
96 template: "Expected an expression, but got '#lexeme'." 116 template: "Expected an expression, but got '#lexeme'."
117 dart2jsCode: FASTA_FATAL
97 118
98 ExpectedFunctionBody: 119 ExpectedFunctionBody:
99 template: "Expected a function body, but got '#lexeme'." 120 template: "Expected a function body, but got '#lexeme'."
121 dart2jsCode: NATIVE_OR_FATAL
100 122
101 ExpectedHexDigit: 123 ExpectedHexDigit:
102 template: "A hex digit (0-9 or A-F) must follow '0x'." 124 template: "A hex digit (0-9 or A-F) must follow '0x'."
103 # No tip, seems obvious from the error message. 125 # No tip, seems obvious from the error message.
126 analyzerCode: MISSING_HEX_DIGIT
127 dart2jsCode: HEX_DIGIT_EXPECTED
104 script: > 128 script: >
105 main() { 129 main() {
106 var i = 0x; 130 var i = 0x;
107 } 131 }
108 132
109 ExpectedIdentifier: 133 ExpectedIdentifier:
110 template: "'#lexeme' is a reserved word and can't be used here." 134 template: "'#lexeme' is a reserved word and can't be used here."
111 tip: "Try using a different name." 135 tip: "Try using a different name."
136 dart2jsCode: EXPECTED_IDENTIFIER
112 script: "do() {} main() {}" 137 script: "do() {} main() {}"
113 138
114 ExpectedOpenParens: 139 ExpectedOpenParens:
115 template: "Expected '('." 140 template: "Expected '('."
141 dart2jsCode: GENERIC
116 142
117 ExpectedString: 143 ExpectedString:
118 template: "Expected a String, but got '#lexeme'." 144 template: "Expected a String, but got '#lexeme'."
145 dart2jsCode: FASTA_FATAL
119 146
120 ExpectedType: 147 ExpectedType:
121 template: "Expected a type, but got '#lexeme'." 148 template: "Expected a type, but got '#lexeme'."
149 dart2jsCode: FASTA_FATAL
122 150
123 ExtraneousModifier: 151 ExtraneousModifier:
124 template: "Can't have modifier '#lexeme' here." 152 template: "Can't have modifier '#lexeme' here."
125 tip: "Try removing '#lexeme'." 153 tip: "Try removing '#lexeme'."
154 dart2jsCode: EXTRANEOUS_MODIFIER
126 script: 155 script:
127 - "var String foo; main(){}" 156 - "var String foo; main(){}"
128 - "var set foo; main(){}" 157 - "var set foo; main(){}"
129 - "var final foo; main(){}" 158 - "var final foo; main(){}"
130 - "var var foo; main(){}" 159 - "var var foo; main(){}"
131 - "var const foo; main(){}" 160 - "var const foo; main(){}"
132 - "var abstract foo; main(){}" 161 - "var abstract foo; main(){}"
133 - "var static foo; main(){}" 162 - "var static foo; main(){}"
134 - "var external foo; main(){}" 163 - "var external foo; main(){}"
135 - "get var foo; main(){}" 164 - "get var foo; main(){}"
136 - "set var foo; main(){}" 165 - "set var foo; main(){}"
137 - "final var foo; main(){}" 166 - "final var foo; main(){}"
138 - "var var foo; main(){}" 167 - "var var foo; main(){}"
139 - "const var foo; main(){}" 168 - "const var foo; main(){}"
140 - "abstract var foo; main(){}" 169 - "abstract var foo; main(){}"
141 - "static var foo; main(){}" 170 - "static var foo; main(){}"
142 - "external var foo; main(){}" 171 - "external var foo; main(){}"
143 172
144 ExtraneousModifierReplace: 173 ExtraneousModifierReplace:
145 template: "Can't have modifier '#lexeme' here." 174 template: "Can't have modifier '#lexeme' here."
146 tip: "Try replacing modifier '#lexeme' with 'var', 'final', or a type." 175 tip: "Try replacing modifier '#lexeme' with 'var', 'final', or a type."
176 dart2jsCode: EXTRANEOUS_MODIFIER_REPLACE
147 script: 177 script:
148 - "set foo; main(){}" 178 - "set foo; main(){}"
149 - "abstract foo; main(){}" 179 - "abstract foo; main(){}"
150 - "static foo; main(){}" 180 - "static foo; main(){}"
151 - "external foo; main(){}" 181 - "external foo; main(){}"
152 182
153 InvalidAwaitFor: 183 InvalidAwaitFor:
154 template: "'await' is only supported in methods with an 'async' or 'async*' bo dy modifier." 184 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." 185 tip: "Try adding 'async' or 'async*' to the method body or removing the 'await ' keyword."
186 dart2jsCode: INVALID_AWAIT_FOR
156 script: > 187 script: >
157 main(o) sync* { 188 main(o) sync* {
158 await for (var e in o) {} 189 await for (var e in o) {}
159 } 190 }
160 191
161 InvalidSyncModifier: 192 InvalidSyncModifier:
162 template: "Invalid modifier 'sync'." 193 template: "Invalid modifier 'sync'."
163 tip: "Try replacing 'sync' with 'sync*'." 194 tip: "Try replacing 'sync' with 'sync*'."
195 dart2jsCode: INVALID_SYNC_MODIFIER
164 script: "main() sync {}" 196 script: "main() sync {}"
165 197
166 InvalidVoid: 198 InvalidVoid:
167 template: "Type 'void' can't be used here because it isn't a return type." 199 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 ." 200 tip: "Try removing 'void' keyword or replace it with 'var', 'final', or a type ."
201 dart2jsCode: VOID_NOT_ALLOWED
169 script: 202 script:
170 - "void x; main() {}" 203 - "void x; main() {}"
171 - "foo(void x) {} main() { foo(null); }" 204 - "foo(void x) {} main() { foo(null); }"
172 205
173 MissingExponent: 206 MissingExponent:
174 template: "Numbers in exponential notation should always contain an exponent ( an integer number with an optional sign)." 207 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." 208 tip: "Make sure there is an exponent, and remove any whitespace before it."
209 analyzerCode: MISSING_DIGIT
210 dart2jsCode: EXPONENT_MISSING
176 script: > 211 script: >
177 main() { 212 main() {
178 var i = 1e; 213 var i = 1e;
179 } 214 }
180 215
181 PositionalParameterWithEquals: 216 PositionalParameterWithEquals:
182 template: "Positional optional parameters can't use ':' to specify a default v alue." 217 template: "Positional optional parameters can't use ':' to specify a default v alue."
183 tip: "Try replacing ':' with '='." 218 tip: "Try replacing ':' with '='."
219 dart2jsCode: POSITIONAL_PARAMETER_WITH_EQUALS
184 script: > 220 script: >
185 main() { 221 main() {
186 foo([a: 1]) => print(a); 222 foo([a: 1]) => print(a);
187 foo(2); 223 foo(2);
188 } 224 }
189 225
190 RequiredParameterWithDefault: 226 RequiredParameterWithDefault:
191 template: "Non-optional parameters can't have a default value." 227 template: "Non-optional parameters can't have a default value."
192 tip: "Try removing the default value or making the parameter optional." 228 tip: "Try removing the default value or making the parameter optional."
229 dart2jsCode: REQUIRED_PARAMETER_WITH_DEFAULT
193 script: 230 script:
194 - > 231 - >
195 main() { 232 main() {
196 foo(a: 1) => print(a); 233 foo(a: 1) => print(a);
197 foo(2); 234 foo(2);
198 } 235 }
199 - > 236 - >
200 main() { 237 main() {
201 foo(a = 1) => print(a); 238 foo(a = 1) => print(a);
202 foo(2); 239 foo(2);
203 } 240 }
204 241
205 StackOverflow: 242 StackOverflow:
206 template: "Stack overflow." 243 template: "Stack overflow."
244 dart2jsCode: GENERIC
207 245
208 UnexpectedDollarInString: 246 UnexpectedDollarInString:
209 template: "A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({})." 247 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 '$'." 248 tip: "Try adding a backslash (\\) to escape the '$'."
249 dart2jsCode: MALFORMED_STRING_LITERAL
211 script: 250 script:
212 - > 251 - >
213 main() { 252 main() {
214 return '$'; 253 return '$';
215 } 254 }
216 - > 255 - >
217 main() { 256 main() {
218 return "$"; 257 return "$";
219 } 258 }
220 - > 259 - >
221 main() { 260 main() {
222 return '''$'''; 261 return '''$''';
223 } 262 }
224 - > 263 - >
225 main() { 264 main() {
226 return """$"""; 265 return """$""";
227 } 266 }
228 267
229 UnexpectedToken: 268 UnexpectedToken:
230 template: "Unexpected token '#lexeme'." 269 template: "Unexpected token '#lexeme'."
270 dart2jsCode: FASTA_FATAL
231 271
232 UnmatchedToken: 272 UnmatchedToken:
233 template: "Can't find '#string' to match '#lexeme'." 273 template: "Can't find '#string' to match '#lexeme'."
274 dart2jsCode: UNMATCHED_TOKEN
234 script: 275 script:
235 - "main(" 276 - "main("
236 - "main(){" 277 - "main(){"
237 - "main(){[}" 278 - "main(){[}"
238 279
239 UnsupportedPrefixPlus: 280 UnsupportedPrefixPlus:
240 template: "'+' is not a prefix operator. " 281 template: "'+' is not a prefix operator. "
241 tip: "Try removing '+'." 282 tip: "Try removing '+'."
283 dart2jsCode: UNSUPPORTED_PREFIX_PLUS
242 script: "main() => +2; // No longer a valid way to write '2'" 284 script: "main() => +2; // No longer a valid way to write '2'"
243 285
244 UnterminatedComment: 286 UnterminatedComment:
245 template: "Comment starting with '/*' must end with '*/'." 287 template: "Comment starting with '/*' must end with '*/'."
288 analyzerCode: UNTERMINATED_MULTI_LINE_COMMENT
289 dart2jsCode: UNTERMINATED_COMMENT
246 script: 290 script:
247 main() { 291 main() {
248 } 292 }
249 /* 293 /*
250 294
251 UnterminatedString: 295 UnterminatedString:
252 template: "String must end with #string." 296 template: "String must end with #string."
297 analyzerCode: UNTERMINATED_STRING_LITERAL
298 dart2jsCode: UNTERMINATED_STRING
253 script: 299 script:
254 - > 300 - >
255 main() { 301 main() {
256 return ' 302 return '
257 ; 303 ;
258 } 304 }
259 - > 305 - >
260 main() { 306 main() {
261 return \" 307 return \"
262 ; 308 ;
(...skipping 13 matching lines...) Expand all
276 - > 322 - >
277 main() => \"\"\" 323 main() => \"\"\"
278 - > 324 - >
279 main() => r''' 325 main() => r'''
280 - > 326 - >
281 main() => r\"\"\" 327 main() => r\"\"\"
282 328
283 UnterminatedToken: 329 UnterminatedToken:
284 # This is a fall-back message that shouldn't happen. 330 # This is a fall-back message that shouldn't happen.
285 template: "Incomplete token." 331 template: "Incomplete token."
332 dart2jsCode: UNTERMINATED_TOKEN
286 333
287 Unspecified: 334 Unspecified:
288 template: "#string" 335 template: "#string"
336 dart2jsCode: GENERIC
289 337
290 AbstractNotSync: 338 AbstractNotSync:
291 template: "Abstract methods can't use 'async', 'async*', or 'sync*'." 339 template: "Abstract methods can't use 'async', 'async*', or 'sync*'."
340 dart2jsCode: FASTA_IGNORED
292 341
293 AsyncAsIdentifier: 342 AsyncAsIdentifier:
343 analyzerCode: ASYNC_KEYWORD_USED_AS_IDENTIFIER
294 template: "'async' can't be used as an identifier in 'async', 'async*', or 'sy nc*' methods." 344 template: "'async' can't be used as an identifier in 'async', 'async*', or 'sy nc*' methods."
345 dart2jsCode: GENERIC
295 346
296 AwaitAsIdentifier: 347 AwaitAsIdentifier:
297 template: "'await' can't be used as an identifier in 'async', 'async*', or 'sy nc*' methods." 348 template: "'await' can't be used as an identifier in 'async', 'async*', or 'sy nc*' methods."
349 dart2jsCode: FASTA_IGNORED
298 350
299 AwaitNotAsync: 351 AwaitNotAsync:
300 template: "'await' can only be used in 'async' or 'async*' methods." 352 template: "'await' can only be used in 'async' or 'async*' methods."
353 dart2jsCode: FASTA_IGNORED
301 354
302 BuiltInIdentifierAsType: 355 BuiltInIdentifierAsType:
303 template: "Can't use '#lexeme' as a type." 356 template: "Can't use '#lexeme' as a type."
357 dart2jsCode: GENERIC
304 358
305 BuiltInIdentifierInDeclaration: 359 BuiltInIdentifierInDeclaration:
306 template: "Can't use '#lexeme' as a name here." 360 template: "Can't use '#lexeme' as a name here."
361 dart2jsCode: GENERIC
307 362
308 AwaitForNotAsync: 363 AwaitForNotAsync:
309 template: "Asynchronous for-loop can only be used in 'async' or 'async*' metho ds." 364 template: "Asynchronous for-loop can only be used in 'async' or 'async*' metho ds."
365 dart2jsCode: FASTA_IGNORED
310 366
311 FactoryNotSync: 367 FactoryNotSync:
312 template: "Factories can't use 'async', 'async*', or 'sync*'." 368 template: "Factories can't use 'async', 'async*', or 'sync*'."
369 dart2jsCode: FASTA_IGNORED
313 370
314 GeneratorReturnsValue: 371 GeneratorReturnsValue:
315 template: "'sync*' and 'async*' can't return a value." 372 template: "'sync*' and 'async*' can't return a value."
373 dart2jsCode: FASTA_IGNORED
316 374
317 InvalidInlineFunctionType: 375 InvalidInlineFunctionType:
318 template: "Invalid inline function type." 376 template: "Invalid inline function type."
319 tip: "Try changing the inline function type (as in 'int f()') to a prefixed fu nction type using the `Function` keyword (as in 'int Function() f')." 377 tip: "Try changing the inline function type (as in 'int f()') to a prefixed fu nction type using the `Function` keyword (as in 'int Function() f')."
378 dart2jsCode: INVALID_INLINE_FUNCTION_TYPE
320 declaration: "typedef F = Function(int f(String x)); main() { F f; }" 379 declaration: "typedef F = Function(int f(String x)); main() { F f; }"
321 380
322 SetterNotSync: 381 SetterNotSync:
323 template: "Setters can't use 'async', 'async*', or 'sync*'." 382 template: "Setters can't use 'async', 'async*', or 'sync*'."
383 dart2jsCode: FASTA_IGNORED
324 384
325 YieldAsIdentifier: 385 YieldAsIdentifier:
326 template: "'yield' can't be used as an identifier in 'async', 'async*', or 'sy nc*' methods." 386 template: "'yield' can't be used as an identifier in 'async', 'async*', or 'sy nc*' methods."
387 dart2jsCode: FASTA_IGNORED
327 388
328 YieldNotGenerator: 389 YieldNotGenerator:
329 template: "'yield' can only be used in 'sync*' or 'async*' methods." 390 template: "'yield' can only be used in 'sync*' or 'async*' methods."
391 dart2jsCode: FASTA_IGNORED
330 392
331 OnlyTry: 393 OnlyTry:
332 template: "Try block should be followed by 'on', 'catch', or 'finally' block." 394 template: "Try block should be followed by 'on', 'catch', or 'finally' block."
333 tip: "Did you forget to add a 'finally' block?" 395 tip: "Did you forget to add a 'finally' block?"
334 statement: "try {}" 396 statement: "try {}"
397 dart2jsCode: FASTA_IGNORED
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/scanner/errors.dart ('k') | pkg/front_end/test/subpackage_relationships_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698