Skip to content

Commit 5931fb5

Browse files
committed
add quick test
1 parent 1665eec commit 5931fb5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/abstractarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ similar(::A,::Type{T},s::Size{S}) where {A<:AbstractArray,T,S} = similar(A,T,s)
130130

131131
# defaults to built-in mutable types for bits types
132132
similar(::Type{A}, ::Type{T}, s::Size{S}) where {A<:AbstractArray,T,S} =
133-
isbitstype(eltype(A)) ?
133+
isbitstype(eltype(T)) ?
134134
mutable_similar_type(T, s, length_val(s))(undef) :
135135
sizedarray_similar_type(T, s, length_val(s))(undef)
136136

test/abstractarray.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ using StaticArrays, Test, LinearAlgebra
5959
sv = @SVector [1,2,3]
6060
sm = @SMatrix [1 2; 3 4]
6161
sa = SArray{Tuple{1,1,1},Int,3,1}((1,))
62+
sn = @SVector [1, missing]
6263

6364
@test isa(@inferred(similar(sv)), MVector{3,Int})
6465
@test isa(@inferred(similar(sv, Float64)), MVector{3,Float64})
@@ -69,6 +70,8 @@ using StaticArrays, Test, LinearAlgebra
6970
@test isa(@inferred(similar(sm, Float64)), MMatrix{2,2,Float64,4})
7071
@test isa(@inferred(similar(sv, Size(3,3))), MMatrix{3,3,Int,9})
7172
@test isa(@inferred(similar(sv, Float64, Size(3,3))), MMatrix{3,3,Float64,9})
73+
@test isa(@inferred(similar(sn)), SizedVector{2, Union{Missing, Int64}, Vector{Union{Missing, Int64}}})
74+
@test isa(@inferred(similar(sn, Float64, Size(3, 3))), MMatrix{3, 3, Float64, 9})
7275

7376
@test isa(@inferred(similar(sa)), MArray{Tuple{1,1,1},Int,3,1})
7477
@test isa(@inferred(similar(SArray{Tuple{1,1,1},Int,3,1})), MArray{Tuple{1,1,1},Int,3,1})

0 commit comments

Comments
 (0)