Skip to content

map of a TrackedArray and a StaticArray is ambiguous #309

Open

Description

@devmotion
using ReverseDiff, StaticArrays
ReverseDiff.gradient(x -> sum(map(+, x, SVector(1.0, 2.0))), [3.0, 4.0])
MethodError: map(::typeof(+), ::ReverseDiff.TrackedArray{Float64, Float64, 1, Vector{Float64}, Vector{Float64}}, ::SVector{2, Float64}) is ambiguous.

ReverseDiff defines map (and broadcast) methods for the functions in DiffRules and SKIPPED_BINARY_SCALAR_FUNCS, with the untracked argument typed as each entry of ARRAY_TYPES (src/derivatives/elementwise.jl). These methods cross StaticArrays' map(f, ::StaticArray, ::AbstractArray...). It's the same kind of ambiguity as the +/-/* ones fixed in #307 (#153).

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions