Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

type parameter UndefVarError when dispatch matches UnionAll #29788

Closed
goretkin opened this issue Oct 24, 2018 · 2 comments
Closed

type parameter UndefVarError when dispatch matches UnionAll #29788

goretkin opened this issue Oct 24, 2018 · 2 comments

Comments

@goretkin
Copy link
Contributor

This behavior surprised me:

sometype = Array{Tuple{R}} where {R}

something(::Type{T}) where {T <: Array{S}} where {S<:Tuple} = S

something(sometype) # gives ERROR: UndefVarError: S not defined

I am not sure if I expected S to be bound to Tuple{R} where {R} or for a MethodError. But either way, I was not expecting S to be ever undefined if it shows up in a where.

versioninfo:

julia> versioninfo()
Julia Version 1.1.0-DEV.318
Commit 993e7d7733 (2018-09-25 06:36 UTC)
@JeffBezanson
Copy link
Member

This is intentional; see #23117. The type is a subtype of the signature, so the method should match. But there is no unique correct value for S.

@goretkin
Copy link
Contributor Author

Thanks for the explanation. I ran into this when using the Size trait of StaticArrays.jl (e.g. Size(SVector)). Looks like I wouldn't have run into it on the master branch of StaticArrays: JuliaArrays/StaticArrays.jl@bfa5536

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants