-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Warn when returning a function invocation when within a try block in an async function #58279
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
This conflicts with |
You shouldn't use We have some discussion about making the |
Just my 2 cents, but I'd strongly prefer a new lint, rather than updating |
@mnordine – Agreed we want a separate lint. But also we should resolve any conflicts between the two lints! |
Actually, this particular behavior should not occur, cf. #44395. So it shouldn't be necessary to help developers remember to include the |
I agree unnecessary_await_in_return might be a common pitfall and either be removed, have a better explanation or an enhanced logic to detect if it is "unnecessary" for sure.. The lint sounds very optimistic about that, but in fact it has a different outcome when trying to catch errors: https://dartpad.dev/340b7252b1e979b6d6fc397e12cb6af8? |
Since #44395 is now on hold in favor of dart-lang/language#870, and that there's no clear timeframe on it landing (it's not even accepted into the language yet), can we get a lint for this in the meantime? |
Agreed. Modifying the language is way more difficult than adding a lint. I think it's valuable to add the lint now, for a quick win. Then once the language is updated, we can depreciate the lint. |
Often if you're in a try block, you want to catch exceptions.
But if you omit the
await
errors might flow through.See https://dartpad.dev/c8deb87cee33b48316fc0f5cf4b1891f
The text was updated successfully, but these errors were encountered: