When I run your code the example with f(rand(Int, 3)) also fails. I don’t think this is too surprising since your code is type unstable. x is changing from an Int to a Float64 here. If we initialize x in a type stable manner, everything is fine:
julia> function f(v)
x = zero(promote_type(Float64, eltype(v)))
@turbo for i ∈ eachindex(v)
amt = v[i] * 0.1
x += amt
f (generic function with 1 method)
julia> f(rand(Int, 2))
julia> f([1, 2])
julia> f([1, 2, 3])
LoopVectorization.jl is pretty brittle around things like this.
Yes, it generally assumes code is type stable.
This is a case where a better error message would be preferable over getting the example to work.
Unfortunately, an error message would probably be more difficult.