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

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

Issue 26370004: Emit a compile-time error when using default values in function typed parameter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 howToFix: "Try replacing ':' with '='.", 580 howToFix: "Try replacing ':' with '='.",
581 examples: const [""" 581 examples: const ["""
582 main() { 582 main() {
583 foo([a: 1]) => print(a); 583 foo([a: 1]) => print(a);
584 foo(2); 584 foo(2);
585 }"""]); 585 }"""]);
586 586
587 static const MessageKind TYPEDEF_FORMAL_WITH_DEFAULT = const MessageKind( 587 static const MessageKind TYPEDEF_FORMAL_WITH_DEFAULT = const MessageKind(
588 "Error: A parameter of a typedef can't specify a default value.", 588 "Error: A parameter of a typedef can't specify a default value.",
589 howToFix: 589 howToFix:
590 "Try removing the default value or making the parameter optional.", 590 "Try removing the default value.",
591 examples: const [""" 591 examples: const ["""
592 typedef void F([int arg = 0]); 592 typedef void F([int arg = 0]);
593 593
594 main() { 594 main() {
595 F f; 595 F f;
596 }""", """ 596 }""", """
597 typedef void F({int arg: 0}); 597 typedef void F({int arg: 0});
598 598
599 main() { 599 main() {
600 F f; 600 F f;
601 }"""]); 601 }"""]);
602 602
603 static const MessageKind FUNCTION_TYPE_FORMAL_WITH_DEFAULT = const MessageKind (
604 "Error: A function type parameters can't specify a default value.",
605 howToFix:
606 "Try removing the default value.",
607 examples: const ["""
608 foo(void f(int i, [a = 1]) {}
609
610 main() {
611 foo(1, 2);
612 }""", """
613 foo(void f(int i, {a: 1}) {}
614
615 main() {
616 foo(1, a: 2);
617 }"""]);
618
603 static const MessageKind FORMAL_DECLARED_CONST = const MessageKind( 619 static const MessageKind FORMAL_DECLARED_CONST = const MessageKind(
604 "Error: A formal parameter can't be declared const.", 620 "Error: A formal parameter can't be declared const.",
605 howToFix: "Try removing 'const'.", 621 howToFix: "Try removing 'const'.",
606 examples: const [""" 622 examples: const ["""
607 foo(const x) {} 623 foo(const x) {}
608 main() => foo(42); 624 main() => foo(42);
609 """, """ 625 """, """
610 foo({const x}) {} 626 foo({const x}) {}
611 main() => foo(42); 627 main() => foo(42);
612 """, """ 628 """, """
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 1446
1431 class CompileTimeConstantError extends Diagnostic { 1447 class CompileTimeConstantError extends Diagnostic {
1432 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse) 1448 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse)
1433 : super(kind, arguments, terse); 1449 : super(kind, arguments, terse);
1434 } 1450 }
1435 1451
1436 class CompilationError extends Diagnostic { 1452 class CompilationError extends Diagnostic {
1437 CompilationError(MessageKind kind, Map arguments, bool terse) 1453 CompilationError(MessageKind kind, Map arguments, bool terse)
1438 : super(kind, arguments, terse); 1454 : super(kind, arguments, terse);
1439 } 1455 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/resolution/members.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698