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

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

Issue 23583035: Emit a compile-time error when returning a value from a constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Include howToFix and example in error message. 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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 493
494 static const MessageKind OPERATOR_OPTIONAL_PARAMETERS = const MessageKind( 494 static const MessageKind OPERATOR_OPTIONAL_PARAMETERS = const MessageKind(
495 'Error: Operator "#{operatorName}" cannot have optional parameters.'); 495 'Error: Operator "#{operatorName}" cannot have optional parameters.');
496 496
497 static const MessageKind OPERATOR_NAMED_PARAMETERS = const MessageKind( 497 static const MessageKind OPERATOR_NAMED_PARAMETERS = const MessageKind(
498 'Error: Operator "#{operatorName}" cannot have named parameters.'); 498 'Error: Operator "#{operatorName}" cannot have named parameters.');
499 499
500 static const MessageKind CONSTRUCTOR_WITH_RETURN_TYPE = const MessageKind( 500 static const MessageKind CONSTRUCTOR_WITH_RETURN_TYPE = const MessageKind(
501 'Error: Cannot have return type for constructor.'); 501 'Error: Cannot have return type for constructor.');
502 502
503 static const MessageKind CANNOT_RETURN_FROM_CONSTRUCTOR = const MessageKind(
504 "Error: Cannot return a value from a constructor.",
ahe 2013/09/05 08:35:20 Prefer "can't" over "cannot" (the guidelines were
505 howToFix: "Remove the return statement or use a factory constructor.",
506 examples: const ["""
507 class C {
508 C() {
509 return 1;
510 }
511 }
512
513 main() => new C();"""]);
514
503 static const MessageKind ILLEGAL_FINAL_METHOD_MODIFIER = const MessageKind( 515 static const MessageKind ILLEGAL_FINAL_METHOD_MODIFIER = const MessageKind(
504 'Error: Cannot have final modifier on method.'); 516 'Error: Cannot have final modifier on method.');
505 517
506 static const MessageKind ILLEGAL_CONSTRUCTOR_MODIFIERS = const MessageKind( 518 static const MessageKind ILLEGAL_CONSTRUCTOR_MODIFIERS = const MessageKind(
507 'Error: Illegal constructor modifiers: "#{modifiers}".'); 519 'Error: Illegal constructor modifiers: "#{modifiers}".');
508 520
509 static const MessageKind ILLEGAL_MIXIN_APPLICATION_MODIFIERS = 521 static const MessageKind ILLEGAL_MIXIN_APPLICATION_MODIFIERS =
510 const MessageKind( 522 const MessageKind(
511 'Error: Illegal mixin application modifiers: "#{modifiers}".'); 523 'Error: Illegal mixin application modifiers: "#{modifiers}".');
512 524
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 1037
1026 class CompileTimeConstantError extends Diagnostic { 1038 class CompileTimeConstantError extends Diagnostic {
1027 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse) 1039 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse)
1028 : super(kind, arguments, terse); 1040 : super(kind, arguments, terse);
1029 } 1041 }
1030 1042
1031 class CompilationError extends Diagnostic { 1043 class CompilationError extends Diagnostic {
1032 CompilationError(MessageKind kind, Map arguments, bool terse) 1044 CompilationError(MessageKind kind, Map arguments, bool terse)
1033 : super(kind, arguments, terse); 1045 : super(kind, arguments, terse);
1034 } 1046 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/typechecker.dart ('k') | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698