Skip to content

Commit

Permalink
Support tracing of binary ops with only one operand being a `Concrete…
Browse files Browse the repository at this point in the history
…RNumber`
  • Loading branch information
giordano committed Feb 16, 2025
1 parent 950e476 commit f95c923
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/TracedRNumber.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,24 @@ for (jlop, hloop) in (
(:(Base.mod), :remainder),
(:(Base.rem), :remainder),
)
@eval function $(jlop)(
@nospecialize(lhs::TracedRNumber{T}), @nospecialize(rhs::TracedRNumber{T})
) where {T}
return Ops.$(hloop)(lhs, rhs)
@eval begin
function $(jlop)(
@nospecialize(lhs::TracedRNumber{T}), @nospecialize(rhs::TracedRNumber{T})
) where {T}
return Ops.$(hloop)(lhs, rhs)
end

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

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

Expand Down

0 comments on commit f95c923

Please sign in to comment.