Skip to content

Commit d70ee20

Browse files
authored
Fix weird dispatch of * with zero arguments (#50411)
1 parent 7fc8646 commit d70ee20

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

stdlib/LinearAlgebra/src/givens.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,9 @@ function *(G1::Givens{S}, G2::Givens{T}) where {S,T}
417417
TS = promote_type(T, S)
418418
Rotation{TS}([convert(AbstractRotation{TS}, G2), convert(AbstractRotation{TS}, G1)])
419419
end
420-
*(G::Givens{T}...) where {T} = Rotation([reverse(G)...])
420+
function *(G::Givens{T}, Gs::Givens{T}...) where {T}
421+
return Rotation([reverse(Gs)..., G])
422+
end
421423
function *(G::Givens{S}, R::Rotation{T}) where {S,T}
422424
TS = promote_type(T, S)
423425
Rotation(vcat(convert(AbstractRotation{TS}, R).rotations, convert(AbstractRotation{TS}, G)))

test/operators.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ Base.convert(::Type{T19714}, ::Int) = T19714()
154154
Base.promote_rule(::Type{T19714}, ::Type{Int}) = T19714
155155
@test T19714()/1 === 1/T19714() === T19714()
156156

157+
@testset "operators with zero argument" begin
158+
@test_throws(MethodError, +())
159+
@test_throws(MethodError, *())
160+
@test isempty(methods(+, ()))
161+
@test isempty(methods(*, ()))
162+
end
163+
157164
# pr #17155 and #33568
158165
@testset "function composition" begin
159166
@test (uppercase(x->string(x,base=16)))(239487) == "3A77F"

0 commit comments

Comments
 (0)