Hi all,
I run over a very surprising type-inference difference. I always thought these two codes would be regarded identical to Julia’s compiler.
make_sigtype_without_bits(::Type{T}) where T<:Tuple = Tuple{_make_sigtype_without_bits.(tuple(T.parameters...))...}
make_sigtype_without_bits2(sigtype) = Tuple{_make_sigtype_without_bits.(tuple(sigtype.parameters...))...}
_make_sigtype_without_bits(element::Type) = element
_make_sigtype_without_bits(bits) = Core.Typeof(bits)
however the difference is huge:
julia> Base.promote_op(make_sigtype_without_bits, Type{Tuple{Int, 1}})
Type{Tuple{Int64, Int64}}
julia> Base.promote_op(make_sigtype_without_bits2, Type{Tuple{Int, 1}})
Type
Does someone know why I need to use explicit where
syntax in order to get the compiler support? What is the semantic difference between the versions explicit-where and no-where-at-all which make for such drastic differences?
Using Julia 1.6.1