Skip to content

Commit 63fb815

Browse files
committed
Resolve ambiguity for convert(::Type{<:Scalar}, ::StaticArray)
1 parent cee335d commit 63fb815

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/convert.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# this covers most conversions and "statically-sized reshapes"
1010
@inline convert(::Type{SA}, sa::StaticArray) where {SA<:StaticArray} = SA(Tuple(sa))
11+
@inline convert(::Type{SA}, sa::StaticArray) where {SA<:Scalar} = SA((sa[],))
1112
@inline convert(::Type{SA}, sa::SA) where {SA<:StaticArray} = sa
1213
@inline convert(::Type{SA}, x::Tuple) where {SA<:StaticArray} = SA(x) # convert -> constructor. Hopefully no loops...
1314

test/convert.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ end # testset
1414
# Issue #651
1515
@testinf SVector{0,Float64}(Any[]) === SVector{0,Float64}()
1616
@testinf SVector{0,Float64}(Int8[]) === SVector{0,Float64}()
17+
18+
# PR #808
19+
@test Scalar{Int}[SVector{1,Int}(3), SVector{1,Float64}(2.0)] == [Scalar{Int}(3), Scalar{Int}(2)]
20+
@test Scalar[SVector{1,Int}(3), SVector{1,Float64}(2.0)] == [Scalar{Int}(3), Scalar{Float64}(2.0)]
1721
end

0 commit comments

Comments
 (0)