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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/typechecker.dart ('k') | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7e8a8d344dba86b57997f909fe187d59d781063a..59055aead79bb4fed3df30f75f7db6944ff659df 100644
--- a/sdk/lib/_internal/compiler/implementation/warnings.dart
+++ b/sdk/lib/_internal/compiler/implementation/warnings.dart
@@ -500,6 +500,18 @@ class MessageKind {
static const MessageKind CONSTRUCTOR_WITH_RETURN_TYPE = const MessageKind(
'Error: Cannot have return type for constructor.');
+ static const MessageKind CANNOT_RETURN_FROM_CONSTRUCTOR = const MessageKind(
+ "Error: Cannot return a value from a constructor.",
ahe 2013/09/05 08:35:20 Prefer "can't" over "cannot" (the guidelines were
+ howToFix: "Remove the return statement or use a factory constructor.",
+ examples: const ["""
+class C {
+ C() {
+ return 1;
+ }
+}
+
+main() => new C();"""]);
+
static const MessageKind ILLEGAL_FINAL_METHOD_MODIFIER = const MessageKind(
'Error: Cannot have final modifier on method.');
« 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