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

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: Address Kathy's comments. 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 a default value.",
434 howToFix:
435 "Try removing the default value or making the parameter optional.",
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 optional parameters can't use '=' to specify a default "
448 "value.",
449 howToFix: "Try replacing '=' with ':'.",
450 examples: const ["""
451 main() {
452 foo({a = 1}) => print(a);
453 foo(a: 2);
454 }"""]);
455
456 static const MessageKind POSITIONAL_PARAMETER_WITH_EQUALS = const MessageKind(
457 "Error: Positional optional parameters can't use ':' to specify a "
458 "default value.",
459 howToFix: "Try replacing ':' with '='.",
460 examples: const ["""
461 main() {
462 foo([a: 1]) => print(a);
463 foo(2);
464 }"""]);
465
432 static const MessageKind TYPEDEF_FORMAL_WITH_DEFAULT = const MessageKind( 466 static const MessageKind TYPEDEF_FORMAL_WITH_DEFAULT = const MessageKind(
433 "Error: A parameter of a typedef can't specify a default value.", 467 "Error: A parameter of a typedef can't specify a default value.",
434 howToFix: "Remove the default value.", 468 howToFix:
469 "Try removing the default value or making the parameter optional.",
435 examples: const [""" 470 examples: const ["""
436 typedef void F([int arg = 0]); 471 typedef void F([int arg = 0]);
437 472
438 main() { 473 main() {
439 F f; 474 F f;
440 }""", """ 475 }""", """
441 typedef void F({int arg: 0}); 476 typedef void F({int arg: 0});
442 477
443 main() { 478 main() {
444 F f; 479 F f;
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 1146
1112 class CompileTimeConstantError extends Diagnostic { 1147 class CompileTimeConstantError extends Diagnostic {
1113 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse) 1148 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse)
1114 : super(kind, arguments, terse); 1149 : super(kind, arguments, terse);
1115 } 1150 }
1116 1151
1117 class CompilationError extends Diagnostic { 1152 class CompilationError extends Diagnostic {
1118 CompilationError(MessageKind kind, Map arguments, bool terse) 1153 CompilationError(MessageKind kind, Map arguments, bool terse)
1119 : super(kind, arguments, terse); 1154 : super(kind, arguments, terse);
1120 } 1155 }
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