Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix weird dispatch of * with zero arguments #50411

Merged
merged 3 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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