You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This problem was originally reported here in Julia discourse. The following is a simplified description of the problem through the discussion there.
Consider a parametrized type MyType with two type parameters N and S, where the range of the inner type parameter S depends on the outer type parameter N:
Note that both mi and mf have the outer type parameter N = 3, and therefore their inner type parameter S must be subtypes of NTuple{3}. However, the information of N in S is lost when an inhomogeneous array of mi and mf is constructed:
julia> vm = [mi, mf]; typeof(vm)
Array{MyType{3,S} where S<:(Tuple{Vararg{T,N}} where T)where N,1}
Notice that the information N = 3 is correctly passed to the element type MyType{3,S} here, but not in S<:(Tuple{Vararg{T,N}} where T) where N. As a result, the following generates an error:
julia> vm::Vector{<:MyType{3}}
ERROR: TypeError: typeassert: expected Array{#s1,1} where #s1<:(MyType{3,S} where S<:(Tuple{T,T,T} where T)), got Array{MyType{3,S} where S<:(Tuple{Vararg{T,N}} where T) where N,1}
The text was updated successfully, but these errors were encountered:
wsshin
changed the title
Inner type parameter depending on outer type parameter lose the fixed outer parameter information
Inner type parameter depending on outer type parameter loses the fixed outer parameter information
Mar 5, 2018
This is the result given by typejoin, which is sometimes lazy and gives a wider type than it could. It should be improved in this case: instead of using the original typevar when corresponding parameters don't match, it should use the typevar obtained after substituting values for prior parameters.
This problem was originally reported here in Julia discourse. The following is a simplified description of the problem through the discussion there.
Consider a parametrized type
MyType
with two type parametersN
andS
, where the range of the inner type parameterS
depends on the outer type parameterN
:Now, create instances of two different
MyType
types—one with a tuple of threeInt64
's and another with a tuple of threeFloat64
's:Note that both
mi
andmf
have the outer type parameterN = 3
, and therefore their inner type parameterS
must be subtypes ofNTuple{3}
. However, the information ofN
inS
is lost when an inhomogeneous array ofmi
andmf
is constructed:Notice that the information
N = 3
is correctly passed to the element typeMyType{3,S}
here, but not inS<:(Tuple{Vararg{T,N}} where T) where N
. As a result, the following generates an error:even though both
mi
andmf
are of typeMyType{3}
:Is this an expected behavior?
The text was updated successfully, but these errors were encountered: