What that @_4::Union{Nothing, Tuple{Int64,Int64}}
is indicating? Where is there any possible Tuple
in this code? Is there anything important about this warning of type evaluation? When one runs @code_warntype
that line is yellow, suggesting that it deserves some attention.
julia> function s(x)
s = 0
for val in x
s = s + val
end
s
end
s (generic function with 1 method)
julia> x = ones(Int64,3);
julia> @code_warntype s(x)
Variables
#self#::Core.Compiler.Const(s, false)
x::Array{Int64,1}
s::Int64
@_4::Union{Nothing, Tuple{Int64,Int64}} #<<<<<<<<< THIS LINE
val::Int64
Body::Int64
1 β (s = 0)
β %2 = x::Array{Int64,1}
β (@_4 = Base.iterate(%2))
β %4 = (@_4 === nothing)::Bool
β %5 = Base.not_int(%4)::Bool
βββ goto #4 if not %5
2 β %7 = @_4::Tuple{Int64,Int64}::Tuple{Int64,Int64}
β (val = Core.getfield(%7, 1))
β %9 = Core.getfield(%7, 2)::Int64
β (s = s + val)
β (@_4 = Base.iterate(%2, %9))
β %12 = (@_4 === nothing)::Bool
β %13 = Base.not_int(%12)::Bool
βββ goto #4 if not %13
3 β goto #2
4 β return s
julia>