Hi, the following code is not correctly inferred in julia 1.7.0.
function test()
k = 1
if k == 1
k = 2
end
return findall(x -> x >= k, [1])
end
julia> @code_warntype(test())
MethodInstance for test()
from test() in Main at none:1
Arguments
#self#::Core.Const(test)
Locals
#17::var"#17#18"
k@_3::Core.Box
k@_4::Union{}
Body::Any
1 ─ Core.NewvarNode(:(#17))
│ (k@_3 = Core.Box())
│ Core.setfield!(k@_3, :contents, 1)
│ %4 = Core.isdefined(k@_3, :contents)::Bool
└── goto #3 if not %4
2 ─ goto #4
3 ─ Core.NewvarNode(:(k@_4))
└── k@_4
4 ┄ %9 = Core.getfield(k@_3, :contents)::Any
│ %10 = (%9 == 1)::Any
└── goto #6 if not %10
5 ─ Core.setfield!(k@_3, :contents, 2)
6 ┄ (#17 = %new(Main.:(var"#17#18"), k@_3))
│ %14 = #17::var"#17#18"
│ %15 = Base.vect(1)::Vector{Int64}
│ %16 = Main.findall(%14, %15)::Any
└── return %16
It is correctly inferred in julia 1.6.1 to an Int64[]
.
Is it expected or should I file an issue ?