Open thetarnav opened 1 month ago
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 non_existing
doesn't exist.
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)
}
odin-bug/main.odin(6:16) Error: Undeclared name: non_existing
for val, i in non_existing {
^~~~~~~~~~~^
odin-bug/main.odin(7:15) Error: Undeclared name: val
fmt.println(val, i)
^~^
odin-bug/main.odin(7:20) Error: Undeclared name: i
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.
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. Also it wouldn't be fun to compile, see few errors, correct them, and compile again only to see more errors that got ignored on the first run.
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