Skip to content

Commit 1083454

Browse files
committed
Fix eltype in empty static array construction (#652)
1 parent 0266ebf commit 1083454

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/convert.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ end
2626
return _convert(SA, a, Length(SA))
2727
end
2828

29-
@inline _convert(SA, a, ::Length{L}) where L = SA(unroll_tuple(a, Length(SA)))
29+
@inline _convert(SA, a, l::Length) = SA(unroll_tuple(a, l))
30+
@inline _convert(SA::Type{<:StaticArray{<:Tuple,T}}, a, ::Length{0}) where T = similar_type(SA, T)(())
3031
@inline _convert(SA, a, ::Length{0}) = similar_type(SA, eltype(a))(())
3132

3233
length_val(a::T) where {T <: StaticArrayLike} = length_val(Size(T))

test/convert.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ end # testset
1010
# Issue #520
1111
@testinf SVector{0}(Int8[]) === SVector{0,Int8}()
1212
@testinf SMatrix{0,0}(zeros(0,0)) === SMatrix{0,0,Float64}(())
13+
14+
# Issue #651
15+
@testinf SVector{0,Float64}(Any[]) === SVector{0,Float64}()
16+
@testinf SVector{0,Float64}(Int8[]) === SVector{0,Float64}()
1317
end

0 commit comments

Comments
 (0)