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

Make @opt_out rrule(...) automatically qualify rrule namespace as ChainRulesCore.rrule #546

Merged
merged 8 commits into from
Feb 23, 2022

Conversation

mzgubic
Copy link
Member

@mzgubic mzgubic commented Feb 21, 2022

Closes #545

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@codecov-commenter
Copy link

codecov-commenter commented Feb 21, 2022

Codecov Report

Merging #546 (e31e979) into main (1d076fa) will increase coverage by 0.04%.
The diff coverage is 92.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #546      +/-   ##
==========================================
+ Coverage   93.41%   93.45%   +0.04%     
==========================================
  Files          15       15              
  Lines         865      871       +6     
==========================================
+ Hits          808      814       +6     
  Misses         57       57              
Impacted Files Coverage Δ
src/rule_definition_tools.jl 96.38% <92.85%> (+0.11%) ⬆️
src/projection.jl 97.30% <0.00%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1d076fa...e31e979. Read the comment docs.

@oxinabox
Copy link
Member

Make @opt_out not evil

This claim is to strong, there is still all kinds of evil 😂

But more seriously for our own future reference it would be good for this PR to have clearer title and description.

As i understand it the core of the problem was if the name rrule did not refer to ChainRulesCore.rrule but to some other function we would not overload ChainRulesCore.rrule but rather that function from the current module.
So this makes it such that we automatically qualify that name

return if call_target == :rrule
_target_rewrite!(qt::QuoteNode, rule_norule) = _target_rewrite!(qt.value, rule_norule)
function _target_rewrite!(call_target::Symbol, rule_norule)
return if call_target == :rrule && rule_norule == :norule
:(ChainRulesCore.no_rrule)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think

Suggested change
:(ChainRulesCore.no_rrule)
:($ChainRulesCore.no_rrule)

might work to actually make this function even if the module name ChainRulesCore isn't in the caller's scope.

If it does then these test could be moved to the isolated macro testing module.
(or a similar setup could be made for this file for testing purposes)
See the setup in
https://github.com/JuliaDiff/ChainRulesCore.jl/blob/main/test/rule_definition_tools.jl#L286

Copy link
Member

@oxinabox oxinabox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I trust you to make appropriate changes then merge when happy

Miha Zgubic and others added 3 commits February 22, 2022 19:07
@mzgubic mzgubic changed the title Make @opt_out not evil Make @opt_out rrule(...) automatically qualify rrule namespace as ChainRulesCore.rrule Feb 22, 2022
@mzgubic mzgubic merged commit e3362cb into main Feb 23, 2022
@mzgubic mzgubic deleted the mz/optout branch February 23, 2022 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@opt_out function checking is evil
3 participants