# Trying to understand output of @code\_warntype

**URL:** <https://discourse.julialang.org/t/trying-to-understand-output-of-code-warntype/28000>\
**Category:** New to Julia\
**Created:** [August 26, 2019, 4:25pm UTC](https://discourse.julialang.org/t/trying-to-understand-output-of-code-warntype/28000 "2019-08-26T16:25:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![klaff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaff/32/7637_2.png) [@klaff](https://discourse.julialang.org/u/klaff)\
**Post date:** [August 26, 2019, 4:25pm UTC](https://discourse.julialang.org/t/trying-to-understand-output-of-code-warntype/28000/1 "2019-08-26T16:25:47Z")

</div>

In the output of @code\_warntype I’m getting a `@_6::Union{Nothing, Tuple{Int64,Int64}}` that I don’t understand. Here’s a MWE

```julia
# Monte Carlo tolerancing

using Random, Distributions, LabelledArrays

"named tuple of distributions of dimensions"
var_dists = (dimA = Truncated(Normal(100, 1.5), 97, 103),
             dimB = Truncated(Normal(106, 1.5), 103, 109))
        
"labelled vector to store sample of dimensions"
vars = @LVector Float64 keys(var_dists)

"takes a sample of the dimensional variables"
function sample_vars!(vars, var_dists)
    for key in keys(var_dists)
        vars[key]=rand(var_dists[key])
    end
end

"compute the resultant for this sample"
function resultant(v)
    v.dimB+v.dimA
end

function simulate(vars, var_dists)
    N = 10000
    r=Vector{Float64}(undef,N)
    for i in 1:N
        sample_vars!(vars, var_dists)
        r[i] = resultant(vars)
    end
    return r
end

@time v=simulate(vars, var_dists)
@code_warntype(simulate(vars, var_dists))

```

which produces

```julia
0.100398 seconds (110.13 k allocations: 7.468 MiB, 3.96% gc time)
Variables
  #self#::Core.Compiler.Const(simulate, false)
  vars::LArray{Float64,1,Array{Float64,1},(:dimA, :dimB)}
  var_dists::NamedTuple{(:dimA, :dimB),Tuple{Truncated{Normal{Float64},Continuous},Truncated{Normal{Float64},Continuous}}}
  N::Int64
  r::Array{Float64,1}
  @_6::Union{Nothing, Tuple{Int64,Int64}}
  i::Int64

Body::Array{Float64,1}
1 ─ (N = 10000)
│ %2 = Core.apply_type(Main.Vector, Main.Float64)::Core.Compiler.Const(Array{Float64,1}, false)
│ (r = (%2)(Main.undef, N::Core.Compiler.Const(10000, false)))
│ %4 = (1:N::Core.Compiler.Const(10000, false))::Core.Compiler.Const(1:10000, false)
│ (@_6 = Base.iterate(%4))
│ %6 = (@_6::Core.Compiler.Const((1, 1), false) === nothing)::Core.Compiler.Const(false, false)
│ %7 = Base.not_int(%6)::Core.Compiler.Const(true, false)
└── goto #4 if not %7
2 ┄ %9 = @_6::Tuple{Int64,Int64}::Tuple{Int64,Int64}
│ (i = Core.getfield(%9, 1))
│ %11 = Core.getfield(%9, 2)::Int64
│ Main.sample_vars!(vars, var_dists)
│ %13 = Main.resultant(vars)::Float64
│ Base.setindex!(r, %13, i)
│ (@_6 = Base.iterate(%4, %11))
│ %16 = (@_6 === nothing)::Bool
│ %17 = Base.not_int(%16)::Bool
└── goto #4 if not %17
3 ─ goto #2
4 ┄ return r

```

Thanks!

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [August 26, 2019, 4:38pm UTC](https://discourse.julialang.org/t/trying-to-understand-output-of-code-warntype/28000/2 "2019-08-26T16:38:51Z")

</div>

My guess is that you’re seeing an internal variable introduced by the iteration protocol (calling `iterate()` on `1:N` will either return a `Tuple{Int, Int}` or `Nothing` depending on whether the iterator has reached its end). The compiler in Julia 1.x is very good at handling these kinds of small unions, so unless this is actually causing a problem for you I would not worry about it at all. You can learn more about the new iterator interface here: [Writing Iterators in Julia 0.7](https://julialang.org/blog/2018/07/iterators-in-julia-0.7)

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [August 26, 2019, 5:05pm UTC](https://discourse.julialang.org/t/trying-to-understand-output-of-code-warntype/28000/3 "2019-08-26T17:05:18Z")

</div>

Note that the output for the variable is printed in yellow to indicate that this is probably not a problem.

---

<div class="post-metadata">

**Author:** ![klaff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaff/32/7637_2.png) [@klaff](https://discourse.julialang.org/u/klaff)\
**Post date:** [August 26, 2019, 7:05pm UTC](https://discourse.julialang.org/t/trying-to-understand-output-of-code-warntype/28000/4 "2019-08-26T19:05:38Z")

</div>

Interesting - I wouldn’t have called that yellow - I would have called it a muddy red (doesn’t help that I’m deuteranomalous), but inspecting the object in my browser says it’s ansi-yellow-intense-fg. In any case it’s the only splash of color on the page.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [August 26, 2019, 7:07pm UTC](https://discourse.julialang.org/t/trying-to-understand-output-of-code-warntype/28000/5 "2019-08-26T19:07:39Z")

</div>

Well, we tell the terminal to print it as yellow at least :).
