-
Notifications
You must be signed in to change notification settings - Fork 1.7k
No analyzer warning or any other errors when I use a timer wrong with =>. #57669
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
I don't think there is anything the analyzer can do, is there? There is also nothing wrong with the function
A function is allowed to contain arbitrary expressions and dart-lang/linter#866 might be related. |
This is an unfortunate side effect of the decision to allow arrow functions with a I don't immediately see a language fix for this, given that we did decide to allow returning values from This feels like a really solid case for a hint or a lint though. To me, it seems clear that:
|
One helping hand could be that the analyzer recognizes that you have a body of a void function with no side-effects. I don't know if the analyzer catches "useless operations" like |
This is not something we are planning to change in the language right now. |
Should be covered by the linter rule |
CC @bwilkerson and @pq; we've recently had a really good discussion on this one, and a lint rule idea. Not sure if another issue for the lint rule idea exists yet. |
I wrote the following code and was surprised when _updateTime was never called:
What the code should have looked like was the following:
The surprising part about this is in the first code set I was returning a function instead of calling it which is invalid as the Timer callback is a void function but I received no run-time or analysis-time errors.
Why I'd expect an error is because this does generate an analysis error which I think is synonymous to the first code set:
_updateTime's signature looks like this:
The text was updated successfully, but these errors were encountered: