Outer constructors with a field of static vector

Dear all,

Can you help me to clarify some point?

Suppose, I have two composite types, one of them is parametric. They look rather similar.

using StaticArrays
struct test1

struct test2{T<:AbstractFloat}

The constructor test1 can convert a vector to a static vector while making the object.

test1(AbstractFloat[1.0, 2.0, 3.0, 4.0, 5.0])

test2 can’t

ERROR: MethodError: no method matching test2(::Array{Float64,1})
Closest candidates are:
test2(::SArray{Tuple{5},T<:AbstractFloat,1,5}) where T<:AbstractFloat at REPL[4]:2.

What is the cause of this difference?

The default constructors generated seem different.

julia> methods(test1)
# 2 methods for type constructor:
[1] test1(t::SArray{Tuple{5},AbstractFloat,1,5}) in Main at REPL[6]:2
[2] test1(t) in Main at REPL[6]:2

julia> methods(test2)
# 1 method for type constructor:
[1] (::Type{test2})(t::SArray{Tuple{5},T,1,5}) where T<:AbstractFloat in Main at REPL[7]:2

test1 has an extra method that can convert any type to an SArray, while test2 doesn’t. You can add your own though:

julia> test2(v::AbstractVector{T}) where {T<:AbstractFloat} = test2{T}(SVector{5,T}(v))

julia> test2([1.0:5.0...])
test2{Float64}([1.0, 2.0, 3.0, 4.0, 5.0])

Thank you so much!