# Question about "type-stability" of Arrays in Julia 0.6

**URL:** <https://discourse.julialang.org/t/question-about-type-stability-of-arrays-in-julia-0-6/5389>\
**Category:** General Usage\
**Tags:** performance, type, arrays, type-stability\
**Created:** [August 15, 2017, 3:49pm UTC](https://discourse.julialang.org/t/question-about-type-stability-of-arrays-in-julia-0-6/5389 "2017-08-15T15:49:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![machakann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/machakann/32/3914_2.png) [@machakann](https://discourse.julialang.org/u/machakann)\
**Post date:** [August 15, 2017, 3:49pm UTC](https://discourse.julialang.org/t/question-about-type-stability-of-arrays-in-julia-0-6/5389/1 "2017-08-15T15:49:07Z")

</div>

Hello! Today I’m reading the doc on [performance tips](https://docs.julialang.org/en/stable/manual/performance-tips/) and started to learning it. I’ve tested the `@code_warntype` macro with some my codes and got a little weird result.

The following function almost do nothing, just make an 1-element Float64 array.

```julia
function test()
    a = ones(Float64, 1)
end

```

For me, it looks it is obvious that type of `a` is Array{Float64,1}, however, the output of `@code_warntype` is:

```julia
Variables:
  #self#::#test
  a::Any

Body:
  begin
      SSAValue(0) = $(Expr(:invoke, MethodInstance for fill!(::Array{Float64,1}, ::Float64), :(Base.fill!), :($(Expr(:foreigncall, :(:jl_alloc_array_1d), Array{Float64,1}, svec(Any, Int64), Array{Float64,1}, 0, 1, 0))), :((Base.sitofp)(Float64, 1)::Float64)))
      return SSAValue(0)
  end::Array{Float64,1}

```

It says type of `a` is not stable (?), thus `Any`. I used julia 0.6 but also tested on julia 0.5.1, then it shows type of `a` is Array{Float64,1} as expected. I would like to ask that there was any change between 0.5.1 and 0.6? Please tell me how to keep “type-stability” for arrays, or just say “don’t mind about that” if it is not important. Thanks.

This is the output of versioninfo().

```julia
Julia Version 0.6.0
Commit 903644385b* (2017-06-19 13:05 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, ivybridge)

```

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [August 15, 2017, 4:03pm UTC](https://discourse.julialang.org/t/question-about-type-stability-of-arrays-in-julia-0-6/5389/2 "2017-08-15T16:03:00Z")

</div>

The compiler realized it didn’t need to use `a` and can just return the temporary array it created for you, so then `a` is `Any` because it’s unused. That started happening in v0.6. There’s an issue open to make this printout more clear.

---

<div class="post-metadata">

**Author:** ![machakann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/machakann/32/3914_2.png) [@machakann](https://discourse.julialang.org/u/machakann)\
**Post date:** [August 16, 2017, 6:43am UTC](https://discourse.julialang.org/t/question-about-type-stability-of-arrays-in-julia-0-6/5389/3 "2017-08-16T06:43:24Z")

</div>

Thank you, I understand.

---

<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 16, 2017, 9:40am UTC](https://discourse.julialang.org/t/question-about-type-stability-of-arrays-in-julia-0-6/5389/4 "2017-08-16T09:40:19Z")

</div>

I started a PR that tries to deal with this problem: [https://github.com/JuliaLang/julia/pull/23280](https://github.com/JuliaLang/julia/pull/23280)
