-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A return statement should not be required in an async method #22091
Comments
This comment was originally written by @seaneagan As with issue #22092, it would have been nice to be able to do: void fuze() async { |
This comment was originally written by @mezoni As in Ruby??? def name How this can be related to current Dart syntax? =========== You propose remove the following rule? ===========
void fuze() async { Believe me it is not good. |
Added Priority-High label. |
This comment was originally written by @Emasoft An async method should NEVER have void as return type! Async void is EVIL. It is a 'fire and forget' insanely dangerous thing. It is the worst language design feature since "goto" (and incidentally for very similar reasons!). It's a well known language design error known to cause only bugs, all almost impossible to track. We suffered enough pain for it in C#, where the very designer of the language admitted the error. Please don't do the same error in Dart. We discussed the problem before here: https://code.google.com/p/dart/issues/detail?id=104 |
This comment was originally written by @seaneagan I'm not sure why "async void" in C# is "fire and forget", but using a "void" return type for "async" methods in dart would be nothing like that. This: void foo async { would be the same as: Futre<Null> foo async { except that it would validate (as much as is possible in a dynamically typed language) that the completion value of the future is not used. Since using |
This comment was originally written by @Emasoft @seaneagan1 wrote:
Have you read the linked issue #104? Or this article? |
This comment was originally written by @seaneagan Yes, I agree that is something that an "extract method" refactoring should handle when code containing an But it's unrelated to the proposal here for |
Set owner to @stereotype441. |
Fixed in revision 43361. Added Fixed label. |
Dart VM version: 1.9.0-dev.6.0 Thanks! Added Verified label. |
This seems to have regressed Dart VM version: 1.9.0-dev.7.1 Attachment: Added Triaged label. |
I'm investigating. |
False alarm: this is still fixed, but not pack-ported to the Java analyzer Added Fixed label. |
@kevmoo Still getting this error displayed in Android Studio with the latest Dart plugin and Dart 2. Compiles fine though. |
Future fuze() async {
await new Future.value();
}
Expected:
no hint/error. This is a valid async method.
Actual:
Hint: This function declares a return type of 'Future', but does not end with a return statement
The text was updated successfully, but these errors were encountered: