-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
-vet-unused-variables
produces unnecessary errors when variable is used as a index
#3943
Comments
So this is kind of a chicken and egg problem. It's saying it is not used because it technically isn't. But it cannot know that because |
It can be confusing, which is why I'm reporting it. But I understand that the solution might not be trivial. It actually happens frequently so maybe I'll just get used to it, or stop using the flag. here is another example: for val, i in non_existing {
fmt.println(val, i)
}
|
A possible solution is only showing vet errors when there are 0 actual compiler errors. Is that a good solution? Maybe. |
There is a compiler error though, which is the whole premise of the issue. |
Which is why a solution is to not show vet errors when there are compiler errors. In this case it would only show the compiler error about using an undeclared variable, and not the vet errors about an unused variable. |
the errors in my last example are not from vet flags actually, so that's not a full solution. |
I don't think there's an (actionable) solution to this then |
^ I actually like laytan's proposal to only show vet errors only when there are no compiler errors The more generic version of this problem is showing inter-dependent errors which I don't think can be solved by patching in one or two lines of code, it has to be done on a case-by-case basis. |
-vet-unused-variables
sometimes produces additional errors about unused variables that are unused, although they are used, just in a line with other errors.This can be confusing and point to a declaration code that is not broken, instead of the actual place that needs correcting.
example:
run:
errors:
I would expect to only see the
Undeclared name: non_existing
error.odin report
The text was updated successfully, but these errors were encountered: