Skip to content

@opt_out scope problem #499

Open
Open
@mcabbott

Description

@mcabbott

This macro only accepts a few functions. But if the ones it accepts aren't imported, it quietly does the wrong thing. Surely this should always make a method for ChainRulesCore.rrule:

julia> using ChainRulesCore: @opt_out

julia> ChainRulesCore.@opt_out *(::Rotation, ::Rotation)
ERROR: LoadError: Unexpected opt-out target. Exprected frule or rrule, got: *

julia> ChainRulesCore.@opt_out rrule(::typeof(*), ::Rotation, ::Rotation)
ERROR: LoadError: UndefVarError: ChainRulesCore not defined
in expression starting at REPL[3]:1

julia> using ChainRulesCore

julia> ChainRulesCore.@opt_out rrule(::typeof(*), ::Rotation, ::Rotation)
rrule (generic function with 1 method)

julia> @macroexpand ChainRulesCore.@opt_out rrule(::typeof(*), ::Rotation, ::Rotation)
quote
    ChainRulesCore.no_rrule(::typeof(*), ::Rotation, ::Rotation) = ChainRulesCore.nothing
    rrule(::typeof(*), ::Rotation, ::Rotation) = ChainRulesCore.nothing
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingrule definition helperrelating to helpers for declaring rules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions