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

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: 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 411
412 static const DualKind NO_SUCH_LIBRARY_MEMBER = const DualKind( 412 static const DualKind NO_SUCH_LIBRARY_MEMBER = const DualKind(
413 error: const MessageKind( 413 error: const MessageKind(
414 'Error: "#{libraryName}" has no member named "#{memberName}".'), 414 'Error: "#{libraryName}" has no member named "#{memberName}".'),
415 warning: const MessageKind( 415 warning: const MessageKind(
416 'Warning: "#{libraryName}" has no member named "#{memberName}".')); 416 'Warning: "#{libraryName}" has no member named "#{memberName}".'));
417 417
418 static const MessageKind CANNOT_INSTANTIATE_TYPEDEF = const MessageKind( 418 static const MessageKind CANNOT_INSTANTIATE_TYPEDEF = const MessageKind(
419 'Error: Cannot instantiate typedef "#{typedefName}".'); 419 'Error: Cannot instantiate typedef "#{typedefName}".');
420 420
421 static const MessageKind REQUIRED_PARAMETER_WITH_DEFAULT = const MessageKind(
422 "Error: Non-optional parameters can't have default a value.",
423 howToFix: "Remove the default value or make the parameter optional.",
ahe 2013/09/13 07:17:05 "Remove ..." sound like a command/order, could you
424 examples: const ["""
425 main() {
426 foo(a: 1) => print(a);
427 foo(2);
428 }""", """
429 main() {
430 foo(a = 1) => print(a);
431 foo(2);
432 }"""]);
433
434 static const MessageKind NAMED_PARAMETER_WITH_EQUALS = const MessageKind(
435 "Error: Named parameters must use ':'.",
ahe 2013/09/13 07:17:05 I have a suspicion that Luke would say this error
436 howToFix: "Change '=' to ':'",
ahe 2013/09/13 07:17:05 Suggestion?
437 examples: const ["""
438 main() {
439 foo({a = 1}) => print(a);
440 foo(a: 2);
441 }"""]);
442
443 static const MessageKind POSITIONAL_PARAMETER_WITH_EQUALS = const MessageKind(
444 "Error: Positional optional parameters must use '='.",
ahe 2013/09/13 07:17:05 Possibly rude, see above.
445 howToFix: "Change ':' to '='",
ahe 2013/09/13 07:17:05 Suggestion?
446 examples: const ["""
447 main() {
448 foo([a: 1]) => print(a);
449 foo(2);
450 }"""]);
451
421 static const MessageKind TYPEDEF_FORMAL_WITH_DEFAULT = const MessageKind( 452 static const MessageKind TYPEDEF_FORMAL_WITH_DEFAULT = const MessageKind(
422 "Error: A parameter of a typedef can't specify a default value.", 453 "Error: A parameter of a typedef can't specify a default value.",
423 howToFix: "Remove the default value.", 454 howToFix: "Remove the default value.",
424 examples: const [""" 455 examples: const ["""
425 typedef void F([int arg = 0]); 456 typedef void F([int arg = 0]);
426 457
427 main() { 458 main() {
428 F f; 459 F f;
429 }""", """ 460 }""", """
430 typedef void F({int arg: 0}); 461 typedef void F({int arg: 0});
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 1131
1101 class CompileTimeConstantError extends Diagnostic { 1132 class CompileTimeConstantError extends Diagnostic {
1102 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse) 1133 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse)
1103 : super(kind, arguments, terse); 1134 : super(kind, arguments, terse);
1104 } 1135 }
1105 1136
1106 class CompilationError extends Diagnostic { 1137 class CompilationError extends Diagnostic {
1107 CompilationError(MessageKind kind, Map arguments, bool terse) 1138 CompilationError(MessageKind kind, Map arguments, bool terse)
1108 : super(kind, arguments, terse); 1139 : super(kind, arguments, terse);
1109 } 1140 }
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