Skip to content

Commit

Permalink
Only define new methods for rem instead of all binary operators
Browse files Browse the repository at this point in the history
They seemed to introduce several ambiguities.
  • Loading branch information
giordano committed Feb 16, 2025
1 parent a36deaa commit b2a1910
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/TracedRNumber.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,23 @@ for (jlop, hloop) in (
(:(Base.mod), :remainder),
(:(Base.rem), :remainder),
)
@eval begin
function $(jlop)(
@nospecialize(lhs::TracedRNumber{T}), @nospecialize(rhs::TracedRNumber{T})
) where {T}
return Ops.$(hloop)(lhs, rhs)
end
@eval function $(jlop)(
@nospecialize(lhs::TracedRNumber{T}), @nospecialize(rhs::TracedRNumber{T})
) where {T}
return Ops.$(hloop)(lhs, rhs)
end
end

function $(jlop)(
@nospecialize(lhs::TracedRNumber{T}), @nospecialize(rhs::Number)
) where {T}
return Ops.$(hloop)(lhs, TracedUtils.promote_to(TracedRNumber{T}, rhs))
end
function Base.rem(
@nospecialize(lhs::TracedRNumber{T}), @nospecialize(rhs::Number)
) where {T}
return Ops.remainder(lhs, TracedUtils.promote_to(TracedRNumber{T}, rhs))
end

function $(jlop)(
@nospecialize(lhs::Number), @nospecialize(rhs::TracedRNumber{T})
) where {T}
return Ops.$(hloop)(TracedUtils.promote_to(TracedRNumber{T}, lhs), rhs)
end
end
function Base.rem(
@nospecialize(lhs::Number), @nospecialize(rhs::TracedRNumber{T})
) where {T}
return Ops.remainder(TracedUtils.promote_to(TracedRNumber{T}, lhs), rhs)
end

function Base.div(@nospecialize(lhs::TracedRNumber{T}), rhs) where {T<:Integer}
Expand Down

0 comments on commit b2a1910

Please sign in to comment.