Closed eddycharly closed 2 years ago
For example, assignments to struct fields are never marked as ineffectual.
Because of this maybe ?
Yes, basically. Assignments to struct fields and array elements are not checked.
I suppose it might not be too much work to check whether a struct/array is ever used (or escapes) after having a field/element assigned to. But I don't plan to do it :)
Thanks for clearing it up ! Do you know a tool that could report the code above as potentially wrong ? (useless assignment, useless code, or any kind of warning that could help drawing a developer attention ?)
This looks obvious that this code is wrong but I fail to find a tool that detects this simple code smell :(
Maybe staticcheck?
staticcheck
didn't report anything :(
Feel free to close the issue.
Let's consider the code below:
Shouldn't this code be reported ?
i.s = "b"
will have no effect here.