julia
julia copied to clipboard
spurious `UndefVarError` for static parameter matching
Perplexing bug on master (but not on v1.10). EDIT: but see below, the basic bug existed already on v1.6
When I run this code in a fresh REPL session, all lines succeed:
f(::Type{<:Tuple{Vararg{A}}}) where {A} = A
f(Tuple{Vararg{Int}})
f(Tuple{Vararg{T}} where {T<:Int})
If the order of the calls to f is reversed, though, both calls error:
julia> f(::Type{<:Tuple{Vararg{A}}}) where {A} = A
f (generic function with 1 method)
julia> f(Tuple{Vararg{T}} where {T<:Int})
ERROR: UndefVarError: `A` not defined in static parameter matching
Suggestion: run Test.detect_unbound_args to detect method arguments that do not fully constrain a type parameter.
Stacktrace:
[1] f(::Type{Tuple{Vararg{T}} where T<:Int64})
@ Main ./REPL[1]:1
[2] top-level scope
@ REPL[2]:1
julia> f(Tuple{Vararg{Int}})
ERROR: UndefVarError: `A` not defined in static parameter matching
Suggestion: run Test.detect_unbound_args to detect method arguments that do not fully constrain a type parameter.
Stacktrace:
[1] f(::Type{Tuple{Vararg{T}} where T<:Int64})
@ Main ./REPL[1]:1
[2] top-level scope
@ REPL[3]:1
Version info:
Julia Version 1.11.0-DEV.1347
Commit 1f111e1326a (2024-01-20 19:02 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × AMD Ryzen 3 5300U with Radeon Graphics
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, znver2)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)