Open wsmoses opened 6 hours ago
Seems reasonable to me? This is where @isdefined
comes in to play.
Howso?
Consider this code which similarly crashes. I would expect this to return nothing.
julia> T = (Vector{Tuple{Code}} where {Code<:Integer})
Array{Tuple{Code}, 1} where Code<:Integer
julia> @inline ptreltype(x) = nothing
ptreltype (generic function with 1 method)
julia> @inline ptreltype(::Type{Array{T,N}}) where {T,N} = T
ptreltype (generic function with 2 methods)
julia> ptreltype(T)
ERROR: UndefVarError: `T` not defined
Stacktrace:
[1] ptreltype(::Type{Array{Tuple{Code}, 1} where Code<:Integer})
@ Main ./REPL[3]:1
[2] top-level scope
@ REPL[4]:1
cc @vchuravy @gbaraldi
It appears to be fixed in v1.11
$ julia +v1.10
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.10.0 (2023-12-25)
_/ |\__'_|_|_|\__'_| |
|__/ |
julia> Type{Vector{Tuple{Code}} where {Code}} <: Type{Vector{T}} where T
true
julia> Type{Vector{Tuple{Code}} where {Code<:Integer}} <: Type{Vector{T}} where T
true
julia> Type{Vector{Tuple{Code}} where {Code<:Integer}} <: Type{Array{T, N}} where {T, N}
true
julia> typeintersect(Type{Vector{Tuple{Code}} where {Code}}, Type{Vector{T}} where T)
Type{Array{Tuple{Code}, 1} where Code}
julia> typeintersect(Type{Vector{Tuple{Code}} where {Code}}, Type{Array{T,N}} where {T,N})
Type{Array{Tuple{Code}, 1} where Code}
julia> typeintersect(Type{Vector{Tuple{Code}} where {Code<:Integer}}, Type{Array{T,N}} where {T,N})
Type{Array{Tuple{Code}, 1} where Code<:Integer}
$ julia +v1.11
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.11.0-rc2.54 (2024-08-19)
_/ |\__'_|_|_|\__'_| | backports-release-1.11/8c60a17508d* (fork: 359 commits, 226 days)
|__/ |
julia> Type{Vector{Tuple{Code}} where {Code}} <: Type{Vector{T}} where T
false
julia> Type{Vector{Tuple{Code}} where {Code<:Integer}} <: Type{Vector{T}} where T
false
julia> Type{Vector{Tuple{Code}} where {Code<:Integer}} <: Type{Array{T, N}} where {T, N}
false
julia> typeintersect(Type{Vector{Tuple{Code}} where {Code}}, Type{Vector{T}} where T)
Union{}
julia> typeintersect(Type{Vector{Tuple{Code}} where {Code}}, Type{Array{T,N}} where {T,N})
Union{}
julia> typeintersect(Type{Vector{Tuple{Code}} where {Code<:Integer}}, Type{Array{T,N}} where {T,N})
Union{}
Any chance whatever the fix was can get backported?
On Julia 1.10.5
Not entirely sure what I would expect here (actually I would expect a methoderror), but definitely not this.
cc @mofeing