Skip to content

Type Stability of Constructor #651

@ranocha

Description

@ranocha

There are some type stability issues (at least for StaticArrays v0.11.0) for an empty SVector:

julia> using StaticArrays

julia> SVector{0, Float64}([])
0-element SArray{Tuple{0},Any,1,0} with indices SOneTo(0)

julia> SVector{0, Float64}(Float64[])
0-element SArray{Tuple{0},Float64,1,0} with indices SOneTo(0)

julia> SVector{0, Float64}(Float32[])
0-element SArray{Tuple{0},Float32,1,0} with indices SOneTo(0)

I expected to get a 0-element SArray{Tuple{0},Float64,1,0} with indices SOneTo(0) in all three cases, similar to the non-empty case:

julia> SVector{1, Float64}([2])
1-element SArray{Tuple{1},Float64,1,1} with indices SOneTo(1):
 2.0

julia> SVector{1, Float64}(Float64[2])
1-element SArray{Tuple{1},Float64,1,1} with indices SOneTo(1):                      
 2.0                                                                                
                                                                                    
julia> SVector{1, Float64}(Float32[2])
1-element SArray{Tuple{1},Float64,1,1} with indices SOneTo(1):                      
 2.0                                                                                

This must have worked at some point in the past, since I got errors caused by this recently on Travis for one of my packages (see https://travis-ci.org/ranocha/SummationByPartsOperators.jl/builds/575385284). The last build before (where everything was fine) has been on 2019-03-07.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions