MWE: if x isa T
does not narrow the type in else
block
#35566
Labels
compiler:inference
Type inference
if x isa T
does not narrow the type in else
block
#35566
This snippet
prints
I expect
%22 = Main._foldl_iter(rf, y, iter, state@_11)::Tuple{Array{Union{Missing, Float64},1}}
instead of%22 = Main._foldl_iter(rf, y, iter, state@_11)::Tuple{Union{Array{Missing,1}, Array{Union{Missing, Float64},1}}}
which has a tuple-of-union. This seems to be due that the argumenty
in#7
is inferred to beTuple{Union{Array{Missing,1}, Array{Union{Missing, Float64},1}}}
. (Indeed, this is what@descend
shows me. Also, I see a corresponding@jl_apply_generic
in the LLVM IR. IIUC this is a sign of a dynamic dispatch.)The type is narrowed as expected if I tweak the example to avoid using intermediate tuple:
prints
It'd be great if this works in the first example too.
Checked with Julia 1.5.0-DEV.630.
The text was updated successfully, but these errors were encountered: