Open tersec opened 7 months ago
But it really is not used as you don't instantiate the generic.
But it really is not used as you don't instantiate the generic.
Exactly. And yet there's no XDeclaredButNotUsed
hint.
Ah, but it is used in the generic lookup pass. :P In fact, the overload is what causes it to be an "open symchoice". Screwed if you emit the warning, screwed if you don't.
This mixes in both n
symbols and soft marks them as used, meaning only the warning is omitted but things like {.error.} don't trigger.
Otherwise this would warn that every n is unused if no code uses foo
:
proc n(x: int) = discard
proc n(x: float) = discard
proc foo*(x: int | float) =
n(x)
The issue is marking the symbol of the proc itself used in general, this also doesn't give an unused warning:
proc foo() =
foo()
The issue is marking the symbol of the proc itself used in general, this also doesn't give an unused warning:
proc foo() = foo()
Sure, https://github.com/nim-lang/Nim/issues/20264 https://github.com/nim-lang/Nim/issues/22274 also an issue, but there's the higher-level semantic argument there (which I disagree with, but it's at least therefore a distinct case) that in some sense recursive functions are always used, by themselves.
This is different because the n(int | int)
is unambugously not used, that Nim does this analysis by soft-marking symbols of the procs notwithstanding, so it's a more unambiguous case.
The real solution here is to type-check generics so that the "pre pass" is not required anymore and it's clear what is going on within a generic (nothing special at all). But lacking this, the overload is not unused since you cannot just remove it and get equivalent behavior in all the edge cases. So a warning would be more harmful then helpful.
Description
Nim Version
Current Output
Expected Output
Possible Solution
No response
Additional Information
No response