# Type Inference Bug with StaticArrays?

**URL:** <https://discourse.julialang.org/t/type-inference-bug-with-staticarrays/13664>\
**Category:** General Usage\
**Created:** [August 18, 2018, 2:43pm UTC](https://discourse.julialang.org/t/type-inference-bug-with-staticarrays/13664 "2018-08-18T14:43:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)\
**Post date:** [August 18, 2018, 2:43pm UTC](https://discourse.julialang.org/t/type-inference-bug-with-staticarrays/13664/1 "2018-08-18T14:43:05Z")

</div>

Consider this simplified example (possibility not quite minimal…)

```nohighlight
test1(x::AbstractVector{TI}, y) where {TI <: Integer} = max.(floor.(TI, x /y), one(TI))

```

then note the `Any` in the type signature of the output:

```julia
julia> test1((@SVector [1,2,3]), rand())
3-element SArray{Tuple{3},Any,1,3}:
 1
 3
 5

```

~~This did not happen on v0.6.x.~~ **EDIT:** The same bug is also present in 0.6.4. It also does not happen if I call `test1([1,2,3], rand())`. It also does not happen for the following variant:

```julia
function test2(x::AbstractVector{TI}, y) where {TI <: Integer}
t = floor.(TI, x /y)
max.(t, one(TI))
end
julia> test2((@SVector [1,2,3]), rand())
3-element SArray{Tuple{3},Int64,1,3}:
 2
 5
 8

```

Probably a bug? But where to file the issue?

EDIT: the behaviour on 0.7 is the same.

---

<div class="post-metadata">

**Author:** ![NiclasMattsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niclasmattsson/32/21988_2.png) [@NiclasMattsson](https://discourse.julialang.org/u/NiclasMattsson)\
**Post date:** [August 18, 2018, 4:21pm UTC](https://discourse.julialang.org/t/type-inference-bug-with-staticarrays/13664/2 "2018-08-18T16:21:43Z")

</div>

> [@cortner](#):
>
> This did not happen on v0.6.x.

Are you sure? I get exactly the same behavior on 0.6.4.

---

<div class="post-metadata">

**Author:** ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)\
**Post date:** [August 18, 2018, 4:44pm UTC](https://discourse.julialang.org/t/type-inference-bug-with-staticarrays/13664/3 "2018-08-18T16:44:09Z")

</div>

Indeed - my mistake. This lack of type inference caused a bug when I was porting to v1.0, which did not appear in 6.4 so I (falsely) assumed that type-inference problem was not present there. I may have made another change that I missed . . . I now edited the title and OP
