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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/warnings.dart

Issue 23456030: Emit compile-time error for incorrectly used optional parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Change error messages. Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 part of dart2js; 5 part of dart2js;
6 6
7 const DONT_KNOW_HOW_TO_FIX = ""; 7 const DONT_KNOW_HOW_TO_FIX = "";
8 8
9 /** 9 /**
10 * The messages in this file should meet the following guide lines: 10 * The messages in this file should meet the following guide lines:
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 warning: const MessageKind( 374 warning: const MessageKind(
375 'Warning: Cannot refer to type variable "#{typeVariableName}" ' 375 'Warning: Cannot refer to type variable "#{typeVariableName}" '
376 'within a static member.')); 376 'within a static member.'));
377 377
378 static const MessageKind TYPE_VARIABLE_IN_CONSTANT = const MessageKind( 378 static const MessageKind TYPE_VARIABLE_IN_CONSTANT = const MessageKind(
379 'Error: Cannot refer to type variable in constant.'); 379 'Error: Cannot refer to type variable in constant.');
380 380
381 static const MessageKind INVALID_TYPE_VARIABLE_BOUND = const MessageKind( 381 static const MessageKind INVALID_TYPE_VARIABLE_BOUND = const MessageKind(
382 "Warning: '#{typeArgument}' is not a subtype of bound '#{bound}' for " 382 "Warning: '#{typeArgument}' is not a subtype of bound '#{bound}' for "
383 "type variable '#{typeVariable}' of type '#{thisType}'.", 383 "type variable '#{typeVariable}' of type '#{thisType}'.",
384 howToFix: "Try to change or remove the type argument.", 384 howToFix: "Try to change or remove the type argument.",
Kathy Walrath 2013/09/13 17:59:08 Try to change or remove -> Try changing or removin
385 examples: const [""" 385 examples: const ["""
386 class C<T extends num> {} 386 class C<T extends num> {}
387 387
388 // 'String' is not a valid instantiation of T with bound num.'. 388 // 'String' is not a valid instantiation of T with bound num.'.
389 main() => new C<String>(); 389 main() => new C<String>();
390 """]); 390 """]);
391 391
392 static const MessageKind INVALID_USE_OF_SUPER = const MessageKind( 392 static const MessageKind INVALID_USE_OF_SUPER = const MessageKind(
393 'Error: "super" not allowed here.'); 393 'Error: "super" not allowed here.');
394 394
(...skipping 27 matching lines...) Expand all
422 422
423 static const DualKind NO_SUCH_LIBRARY_MEMBER = const DualKind( 423 static const DualKind NO_SUCH_LIBRARY_MEMBER = const DualKind(
424 error: const MessageKind( 424 error: const MessageKind(
425 'Error: "#{libraryName}" has no member named "#{memberName}".'), 425 'Error: "#{libraryName}" has no member named "#{memberName}".'),
426 warning: const MessageKind( 426 warning: const MessageKind(
427 'Warning: "#{libraryName}" has no member named "#{memberName}".')); 427 'Warning: "#{libraryName}" has no member named "#{memberName}".'));
428 428
429 static const MessageKind CANNOT_INSTANTIATE_TYPEDEF = const MessageKind( 429 static const MessageKind CANNOT_INSTANTIATE_TYPEDEF = const MessageKind(
430 'Error: Cannot instantiate typedef "#{typedefName}".'); 430 'Error: Cannot instantiate typedef "#{typedefName}".');
431 431
432 static const MessageKind REQUIRED_PARAMETER_WITH_DEFAULT = const MessageKind(
433 "Error: Non-optional parameters can't have default a value.",
Kathy Walrath 2013/09/13 17:59:08 default a value -> a default value
karlklose 2013/09/16 07:58:59 Done.
434 howToFix:
435 "Try removing the default value or make the parameter optional.",
Kathy Walrath 2013/09/13 17:59:08 This should be: Try removing the default value or
karlklose 2013/09/16 07:58:59 Done.
436 examples: const ["""
437 main() {
438 foo(a: 1) => print(a);
439 foo(2);
440 }""", """
441 main() {
442 foo(a = 1) => print(a);
443 foo(2);
444 }"""]);
445
446 static const MessageKind NAMED_PARAMETER_WITH_EQUALS = const MessageKind(
447 "Error: Named parameters use ':' to specify a default value.",
Kathy Walrath 2013/09/13 17:59:08 Shouldn't this mention/describe the error/problem?
karlklose 2013/09/16 07:58:59 Done.
448 howToFix: "Try replacing '=' with ':'.",
449 examples: const ["""
450 main() {
451 foo({a = 1}) => print(a);
452 foo(a: 2);
453 }"""]);
454
455 static const MessageKind POSITIONAL_PARAMETER_WITH_EQUALS = const MessageKind(
456 "Error: Positional optional parameters use '=' to specify a default "
Kathy Walrath 2013/09/13 17:59:08 Again, this doesn't describe the error. Maybe: E
karlklose 2013/09/16 07:58:59 Done.
457 "value.",
458 howToFix: "Try replacing ':' with '='.",
459 examples: const ["""
460 main() {
461 foo([a: 1]) => print(a);
462 foo(2);
463 }"""]);
464
432 static const MessageKind TYPEDEF_FORMAL_WITH_DEFAULT = const MessageKind( 465 static const MessageKind TYPEDEF_FORMAL_WITH_DEFAULT = const MessageKind(
433 "Error: A parameter of a typedef can't specify a default value.", 466 "Error: A parameter of a typedef can't specify a default value.",
434 howToFix: "Remove the default value.", 467 howToFix:
468 "Try removing the default value or making the parameter optional.",
435 examples: const [""" 469 examples: const ["""
436 typedef void F([int arg = 0]); 470 typedef void F([int arg = 0]);
437 471
438 main() { 472 main() {
439 F f; 473 F f;
440 }""", """ 474 }""", """
441 typedef void F({int arg: 0}); 475 typedef void F({int arg: 0});
442 476
443 main() { 477 main() {
444 F f; 478 F f;
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 1145
1112 class CompileTimeConstantError extends Diagnostic { 1146 class CompileTimeConstantError extends Diagnostic {
1113 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse) 1147 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse)
1114 : super(kind, arguments, terse); 1148 : super(kind, arguments, terse);
1115 } 1149 }
1116 1150
1117 class CompilationError extends Diagnostic { 1151 class CompilationError extends Diagnostic {
1118 CompilationError(MessageKind kind, Map arguments, bool terse) 1152 CompilationError(MessageKind kind, Map arguments, bool terse)
1119 : super(kind, arguments, terse); 1153 : super(kind, arguments, terse);
1120 } 1154 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/scanner/parser.dart ('k') | sdk/lib/html/html_common/conversions.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698