Skip to content

Commit

Permalink
Fix tuple increment inference
Browse files Browse the repository at this point in the history
  • Loading branch information
willtebbutt committed Feb 3, 2025
1 parent b04df89 commit 3a667d9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/tangents.jl
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,9 @@ increment_internal!!(::IncCache, x::T, y::T) where {T<:IEEEFloat} = x + y
function increment_internal!!(::IncCache, x::Ptr{T}, y::Ptr{T}) where {T}
return x === y ? x : throw(error("eurgh"))

Check warning on line 618 in src/tangents.jl

View check run for this annotation

Codecov / codecov/patch

src/tangents.jl#L617-L618

Added lines #L617 - L618 were not covered by tests
end
function increment_internal!!(c::IncCache, x::T, y::T) where {T<:Tuple}
return tuple_map((x, y) -> increment_internal!!(c, x, y), x, y)::T
@generated function increment_internal!!(c::IncCache, x::T, y::T) where {T<:Tuple}
inc_exprs = map(n -> :(increment_internal!!(c, x[$n], y[$n])), 1:fieldcount(T))
return Expr(:(::), Expr(:call, :tuple, inc_exprs...), T)
end
function increment_internal!!(c::IncCache, x::T, y::T) where {T<:NamedTuple}
return T(tuple_map((x, y) -> increment_internal!!(c, x, y), x, y))
Expand Down

0 comments on commit 3a667d9

Please sign in to comment.