You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is essentially because the check, as written, only works on local, non-escaping variables. It bails out as soon as a variable's address is taken. We cannot trivially determine if the variable is being read at some point or not once its address has been taken. We'll have to do whole program analysis and take pointer aliasing into consideration.
Found this while refactoring something. Consider this code:
Staticcheck will correctly warn that the second value of
err
is never used:But if we use closures, staticcheck fails to detect the bug:
This code generates no warnings, despite the fact that
err
is unchecked.The text was updated successfully, but these errors were encountered: