-
Notifications
You must be signed in to change notification settings - Fork 1.7k
discarded_futures false positive? #59387
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
Comments
There are other similar reports. The documentation for the lint states that the thing it warns about is calling an asynchronous function in a non- You do that, calling (The lint is confusingly named, which is probably one of the reasons for the many reports of it not doing what people think it should be doing.) |
Yes, I understand what it's supposed to do, but for some reason I was under the impression that it has built-in exceptions where it doesn't report it (because it knows the 'bigger picture'), and framework functions could be among the exceptions. Especially because I have cases where the lint isn't triggered, but I am calling a function returning a |
Ok, I know now what the difference is in my code snippet that doesn't trigger the lint, I have a getter instead of a function calll: Stream<int> foo() {
return Stream.fromFuture(futureInt); // <== no lint
}
Future<int> get futureInt => Future.value(17); I guess this is also expected, because the lint doc say 'Making asynchronous calls in non-async functions', and a getter returning a Future is not an async call? |
I can't see why we wouldn't consider a getter invocation to be a function invocation in this context. A future which is obtained by calling a getter would, presumably, be just as worthy of a lint message as a future returned by a method invocation—if the latter is dangerous/error-prone then the former would be equally so. I've added the label 'false-negative' because this behavior is very likely to be considered as such. The behavior which was reported initially (and mentioned in the issue title) was a false positive. I'm not so sure it is a false positive, based on the description of the lint, but I added the label 'false-positive' as well because it was described as such. |
That's one interpretation. My more cyncical interpretation is that the lint is vaguely specified and therefore inconsistently implemented. I'd assume the intent of the lint to be captured by "never have an expression with a type of |
Describe the issue
A possible false positive for the
discarded_futures
lint.To Reproduce
Expected behavior
I think the lint shouldn't be triggered, the
Future
isn't discarded, it is consumed byStream.fromFuture
.The text was updated successfully, but these errors were encountered: