-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Unreachable reached (1.5.0-beta1 & 1.4.0) #36443
Comments
Seems to work on master. |
Finally got to compiling julia from source: Yes, works on master for me too. Still failing on 1.5.0-rc1, so I guess the fix will be in 1.5.1? |
If the PR that fixes it is identified and is eligible for backporting. The best way to find it is usually to do a bisection. |
I unfortunately don't quite have the git-fu and time to do that. I'm fine closing this and waiting for 1.6 too, I can probably work around the bug until then. |
Bisect took me to cb41bbb, but that probably only circumvents some underlying bug here. |
Further reduction which also crashes on master: struct Joe{N}
Joe{N}(tup::NTuple{N}, sym::Symbol) where {N} = new()
end
Joe{N}(tup::NTuple{N}) where {N} = Joe{2}(tup, :a)
function bugfunc(::Type{T}) where {T}
tup1 = Tuple{Any, Vararg}[(:a, :b)][1]
T(tup1)
end
bugfunc(Joe{2}) Inference gets something wrong here: julia> @code_typed bugfunc(Joe{2})
CodeInfo(
1 ─ %1 = $(Expr(:foreigncall, :(:jl_alloc_array_1d), Array{Tuple{Any,Vararg{Any,N} where N},1}, svec(Any, Int64), 0, :(:ccall), Array{Tuple{Any,Vararg{Any,N} where N},1}, 1, 1))::Array{Tuple{Any,Vararg{Any,N} where N},1}
│ Base.arrayset(false, %1, (:a, :b), 1)::Array{Tuple{Any,Vararg{Any,N} where N},1}
│ %3 = Base.arrayref(true, %1, 1)::Tuple{Any,Vararg{Any,N} where N}
│ ($(Expr(:static_parameter, 1)))(%3)::Union{}
└── unreachable
) => Union{}
julia> code_typed(Joe{2}, (Tuple{Any,Vararg},))
1-element Array{Any,1}:
CodeInfo(
1 ─ (Joe{2})(tup, :a)::Union{}
└── unreachable
) => Union{}
julia> Joe{2}((:a, :b))
Joe{2}() |
Slight further reduction: struct Joe{N}
Joe{N}(tup::NTuple{N}) where {N} = new()
end
joe(tup::NTuple) = Joe{2}(tup)
function bugfunc()
tup1 = Tuple{Any, Vararg}[(:a, :b)][1]
joe(tup1)
end
bugfunc() The problem is julia> methods(Joe{2}, Tuple{Tuple{T,Vararg{T,N}} where T where N})
# 0 methods for type constructor: due to this type intersection problem: julia> typeintersect(Tuple{Type{Joe{N}},Tuple{Vararg{T,N}} where T} where N, Tuple{Type{Joe{2}},Tuple{T,Vararg{T,N}} where T} where N)
Union{} # should be Tuple{Type{Joe{2}},Tuple{Vararg{T,2}} where T} Note that these work: julia> typeintersect(Tuple{Type{Joe{N}},Tuple{Vararg{T,N}} where T} where N, Tuple{Type{Joe{2}},Tuple{Vararg{T,N}} where T} where N)
Tuple{Type{Joe{2}},Tuple{Vararg{T,2}} where T}
julia> typeintersect(Tuple{Type{Joe{N}},Tuple{Vararg{T,N}} where T} where N, Tuple{Type{Joe{2}},Tuple{T,T,Vararg{T,N}} where T} where N)
Tuple{Type{Joe{2}},Tuple{T,T} where T} |
Taking the M in MWE seriously: |
Doesn't seem to crash now. |
As analyzed already, the originally reported reproducer was accidentally fixed by cb41bbb, but the underlying issue is still exhibited by the reduced versions from #36443 (comment), #36443 (comment), and #36443 (comment). |
I have reached the unreachable using the following
bugscript.jl:
:As mentioned in the title, this happens on at least 1.4.0 and 1.5.0-beta1.
The above is pretty much the smallest example I could reduce this down to, but let me know if I can do something else to help track this down further.
The text was updated successfully, but these errors were encountered: