Skip to content

Commit

Permalink
Fix weird dispatch of * with zero arguments (JuliaLang#50411)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdalle authored Jul 5, 2023
1 parent 7fc8646 commit d70ee20
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion stdlib/LinearAlgebra/src/givens.jl
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,9 @@ function *(G1::Givens{S}, G2::Givens{T}) where {S,T}
TS = promote_type(T, S)
Rotation{TS}([convert(AbstractRotation{TS}, G2), convert(AbstractRotation{TS}, G1)])
end
*(G::Givens{T}...) where {T} = Rotation([reverse(G)...])
function *(G::Givens{T}, Gs::Givens{T}...) where {T}
return Rotation([reverse(Gs)..., G])
end
function *(G::Givens{S}, R::Rotation{T}) where {S,T}
TS = promote_type(T, S)
Rotation(vcat(convert(AbstractRotation{TS}, R).rotations, convert(AbstractRotation{TS}, G)))
Expand Down
7 changes: 7 additions & 0 deletions test/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ Base.convert(::Type{T19714}, ::Int) = T19714()
Base.promote_rule(::Type{T19714}, ::Type{Int}) = T19714
@test T19714()/1 === 1/T19714() === T19714()

@testset "operators with zero argument" begin
@test_throws(MethodError, +())
@test_throws(MethodError, *())
@test isempty(methods(+, ()))
@test isempty(methods(*, ()))
end

# pr #17155 and #33568
@testset "function composition" begin
@test (uppercase(x->string(x,base=16)))(239487) == "3A77F"
Expand Down

0 comments on commit d70ee20

Please sign in to comment.