# Any workaround for this core Julia bug causing spurious \`UndefVarError\`?

**URL:** https://discourse.julialang.org/t/any-workaround-for-this-core-julia-bug-causing-spurious-undefvarerror/109083
**Category:** General Usage
**Tags:** bug, type, parametric-methods
**Created:** [January 22, 2024, 6:45am UTC](https://discourse.julialang.org/t/any-workaround-for-this-core-julia-bug-causing-spurious-undefvarerror/109083 "2024-01-22T06:45:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)
#### Post date: [January 22, 2024, 6:45am UTC](https://discourse.julialang.org/t/any-workaround-for-this-core-julia-bug-causing-spurious-undefvarerror/109083/1 "2024-01-22T06:45:14Z")

</div>

> <https://github.com/JuliaLang/julia/issues/52992>
>
> 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:
> 
> \`\`\`julia
> 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-repl
> 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)
> \`\`\`

This script succeeds as expected (run as script or try in a fresh REPL session):

```julia
f(::Type{<:Tuple{Vararg{A}}}) where {A} = A
struct S end
f(Tuple{Vararg{S}})
f(Tuple{Vararg{T}} where {T<:S})

```

But if the order of the calls to `f` is reversed, exchanging the last two lines, all calls of `f` fail. With any Julia version I tried.

Can anyone think of a workaround? My perspective is that I want to write a function like `f` that should work for all possible `A`, not just for known types like `S`.
