-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Erroneous warning when using types in keyword argument function declaration #49275
Comments
It seems to be an issue with the way lowering decided if a variable gets used (not checking recursively). If we try some other combinations, we can see it handles it correctly if it is entirely unused:
|
This issue seem to apply also to optional positional arguments, not just keyword arguments: julia> f(a::T = Int[]) where {N, T <: AbstractVector{N}} = zero(N)
WARNING: method definition for f at REPL[1]:1 declares type variable N but does not use it.
f (generic function with 2 methods) |
FWIW, I also encountered this issue. |
I just noticed this bug while porting the code to JuliaLowering.jl and set out to prove it ... and landed here :) This is fixed in the JuliaLowering.jl implementation - the fix, conceptually, is to traverse the graph of symbolic dependencies between type variables, only picking up type variables which are used directly in the function arguments, or transitive dependencies of such. The broken flisp lowering code for default args case is here: Line 655 in 858cb62
|
If I have a function with a nested type delegation (two
where
s), I get the following incorrect warningIt is being used, as can be seen by these two executions of the function
If I do something similar without nesting the type, it works fine with no warning
Ran on 1.8.5 and latest 1.9 RC
The text was updated successfully, but these errors were encountered: