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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/warnings.dart
diff --git a/sdk/lib/_internal/compiler/implementation/warnings.dart b/sdk/lib/_internal/compiler/implementation/warnings.dart
index f8248d45d2b223c9e342b783fbb09fd1597e25d7..899aa7804e260a119ddf512c97924408399784fe 100644
--- a/sdk/lib/_internal/compiler/implementation/warnings.dart
+++ b/sdk/lib/_internal/compiler/implementation/warnings.dart
@@ -429,9 +429,43 @@ main() => new C<String>();
static const MessageKind CANNOT_INSTANTIATE_TYPEDEF = const MessageKind(
'Error: Cannot instantiate typedef "#{typedefName}".');
+ static const MessageKind REQUIRED_PARAMETER_WITH_DEFAULT = const MessageKind(
+ "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.
+ howToFix:
+ "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.
+ examples: const ["""
+main() {
+ foo(a: 1) => print(a);
+ foo(2);
+}""", """
+main() {
+ foo(a = 1) => print(a);
+ foo(2);
+}"""]);
+
+ static const MessageKind NAMED_PARAMETER_WITH_EQUALS = const MessageKind(
+ "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.
+ howToFix: "Try replacing '=' with ':'.",
+ examples: const ["""
+main() {
+ foo({a = 1}) => print(a);
+ foo(a: 2);
+}"""]);
+
+ static const MessageKind POSITIONAL_PARAMETER_WITH_EQUALS = const MessageKind(
+ "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.
+ "value.",
+ howToFix: "Try replacing ':' with '='.",
+ examples: const ["""
+main() {
+ foo([a: 1]) => print(a);
+ foo(2);
+}"""]);
+
static const MessageKind TYPEDEF_FORMAL_WITH_DEFAULT = const MessageKind(
"Error: A parameter of a typedef can't specify a default value.",
- howToFix: "Remove the default value.",
+ howToFix:
+ "Try removing the default value or making the parameter optional.",
examples: const ["""
typedef void F([int arg = 0]);
« 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