Skip to content
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

spurious UndefVarError for static parameter matching #52992

Open
nsajko opened this issue Jan 21, 2024 · 2 comments
Open

spurious UndefVarError for static parameter matching #52992

nsajko opened this issue Jan 21, 2024 · 2 comments
Labels
domain:types and dispatch Types, subtyping and method dispatch kind:bug Indicates an unexpected problem or unintended behavior

Comments

@nsajko
Copy link
Contributor

nsajko commented Jan 21, 2024

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)
@nsajko nsajko added kind:bug Indicates an unexpected problem or unintended behavior kind:regression Regression in behavior compared to a previous version domain:types and dispatch Types, subtyping and method dispatch labels Jan 21, 2024
@nsajko
Copy link
Contributor Author

nsajko commented Jan 21, 2024

This reproduces with b74daf5 (#51388), but not with its parent 29f2b2f. Even though b74daf5 only changes stdlibs.

@nsajko
Copy link
Contributor Author

nsajko commented Jan 21, 2024

A similar reproducer, using a newly defined type (S) instead of Int, reproduces the bug all the way up to v1.6.7:

Works fine:

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

Errors:

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

@nsajko nsajko removed the kind:regression Regression in behavior compared to a previous version label Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:types and dispatch Types, subtyping and method dispatch kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

1 participant