Skip to content

Commit 559134c

Browse files
authored
Fix issue #961 (#962)
* Fix issue #961 * only test on newer Julia versions * bump version
1 parent 47c06fc commit 559134c

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "StaticArrays"
22
uuid = "90137ffa-7385-5640-81b9-e52037218182"
3-
version = "1.2.12"
3+
version = "1.2.13"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/linalg.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ end
139139
end
140140
end
141141

142-
@generated function diagm(kvs::Pair{<:Val,<:StaticVector}...)
142+
@generated function diagm(kv1::Pair{<:Val,<:StaticVector}, other_kvs::Pair{<:Val,<:StaticVector}...)
143+
kvs = (kv1, other_kvs...)
143144
diag_ind_and_length = [(kv.parameters[1].parameters[1], length(kv.parameters[2])) for kv in kvs]
144145
N = maximum(abs(di) + dl for (di,dl) in diag_ind_and_length)
145146
vs = [Symbol("v$i") for i=1:length(kvs)]
@@ -153,6 +154,7 @@ end
153154
end
154155
return quote
155156
$(Expr(:meta, :inline))
157+
kvs = (kv1, other_kvs...)
156158
$(vs_exprs...)
157159
@inbounds elements = tuple($(element_exprs...))
158160
T = promote_tuple_eltype(elements)

test/linalg.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ StaticArrays.similar_type(::Union{RotMat2,Type{RotMat2}}) = SMatrix{2,2,Float64,
117117
end
118118

119119
@testset "diagm()" begin
120+
if VERSION >= v"1.3"
121+
@test diagm() isa BitArray # issue #961: type piracy of zero-arg diagm
122+
# `diagm()` fails on older version of Julia even without StaticArrays.jl
123+
end
120124
@test @inferred(diagm(SA[1,2])) === SA[1 0; 0 2]
121125
@test @inferred(diagm(Val(0) => SVector(1,2))) === @SMatrix [1 0; 0 2]
122126
@test @inferred(diagm(Val(2) => SVector(1,2,3)))::SMatrix == diagm(2 => [1,2,3])

0 commit comments

Comments
 (0)