Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@opt_out scope problem #499

Open
mcabbott opened this issue Oct 23, 2021 · 1 comment
Open

@opt_out scope problem #499

mcabbott opened this issue Oct 23, 2021 · 1 comment
Labels
bug Something isn't working rule definition helper relating to helpers for declaring rules

Comments

@mcabbott
Copy link
Member

mcabbott commented Oct 23, 2021

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
@oxinabox
Copy link
Member

Yes, it would be good to fix this.
This is on me, I knew it wasn't scoping right but wanted to get it in for the 1.0 deadline so we could test it and change it is it's API was wrong.

I probably should have openned an issue about it when the original PR was merged.

@oxinabox oxinabox added bug Something isn't working rule definition helper relating to helpers for declaring rules labels Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rule definition helper relating to helpers for declaring rules
Projects
None yet
Development

No branches or pull requests

2 participants