-
-
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
State dependent type construction? #16618
Comments
@dpsanders and I were taking a look at this and found there are issues with the dispatch of julia> convert(Array{Tuple{Any, Any}}, Array{Tuple{Any, Any}}())
0-dimensional Array{Tuple{Any,Any},0}:
#undef
julia> convert(Array{Tuple{Vararg{Any, 2}}}, Array{Tuple{Vararg{Any, 2}}}())
ERROR: UndefRefError: access to undefined reference
in unsafe_copy!(::Array{Tuple{Any,Any},0}, ::Int64, ::Array{Tuple{Any,Any},0}, ::Int64, ::Int64) at ./array.jl:51
in copy!(::Array{Tuple{Any,Any},0}, ::Int64, ::Array{Tuple{Any,Any},0}, ::Int64, ::Int64) at ./array.jl:62
in convert(::Type{Array{Tuple{Vararg{Any,2}},N}}, ::Array{Tuple{Any,Any},0}) at ./array.jl:200
in eval(::Module, ::Any) at ./boot.jl:225
in macro expansion at ./REPL.jl:92 [inlined]
in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:46
julia> @which convert(Array{Tuple{Any, Any}}, Array{Tuple{Any, Any}}())
convert{T,n}(::Type{Array{T,N<:Any}}, x::Array{T,n}) at array.jl:197
julia> @which convert(Array{Tuple{Vararg{Any, 2}}}, Array{Tuple{Vararg{Any, 2}}}())
convert{T,n,S}(::Type{Array{T,N<:Any}}, x::AbstractArray{S,n}) at array.jl:200 The reciprocal has similar results. I believe the crux of the bug is based around: julia> Array{Tuple{Any, Any}}()
0-dimensional Array{Tuple{Any,Any},0}:
#undef
julia> Array{Tuple{Vararg{Any,2}}}()
0-dimensional Array{Tuple{Any,Any},0}:
#undef Where, in a new session, the reciprocal holds as well. It seems to me that there is an issue with dispatch on object instantiation, since julia> Array{Tuple{Any,Any}}
Array{Tuple{Any,Any},N}
julia> Array{Tuple{Vararg{Any,2}}}
Array{Tuple{Vararg{Any,2}},N} I think the following probably has something to do with all of this: julia> Base.typeseq(Tuple{Vararg{Any, 2}}, Tuple{Any,Any})
true This also occurs with user defined types julia> type A{T}
x::T
A() = new()
end
julia> A{Tuple{Any,Any}}()
A{Tuple{Any,Any}}(#undef)
julia> A{Tuple{Vararg{Any, 2}}}()
A{Tuple{Any,Any}}(#undef) |
|
Huh. Why is it that Is what you're saying that the bug here is the dispatch at convert, and the state-dependent object instantiation should be inconsequential? |
|
Yeah, I checked that when you mentioned it. That's why I'm confused by the types julia> NTuple
Tuple{Vararg{T,N}}
julia> NTuple{2, Any} === Tuple{Vararg{Any,2}}
false
julia> NTuple{2, Any} === Tuple{Any, Any}
true |
Fixed by #17361 |
may as well add the additional test case from here, just in case |
Basically, instantiating one of these types before the other causes instantiation of the latter to throw an
UndefRefError
.In a new session
I found this in JuMP occurring with calls to
JuMP._similar
fromgetvalue
. Similar errors didn't occur for Arrays, or a user defined type, so I think it's Dict specific. The value type doesn't seem to matter to this error.The text was updated successfully, but these errors were encountered: