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

Test for things adding rules to DataType/UnionAll #563

Merged
merged 5 commits into from
Jan 26, 2022
Merged

Conversation

oxinabox
Copy link
Member

This should let us catch errors like
#562
before they are merged.

idk if this is the best way, feedback appreciated.

The output this will show is:

┌ Error: Bad constructor rrule. typeof(T)` not `Type{T}`
│   method = rrule(::UnionAll, x::AbstractArray, perm) in ChainRules at /home/oxinabox/JuliaEnvs/ChainRulesWorld/ChainRules.jl/src/rulesets/Base/array.jl:84
└ @ Main ~/JuliaEnvs/ChainRulesWorld/ChainRules.jl/test/global_state.jl:24
Test Failed at /home/oxinabox/JuliaEnvs/ChainRulesWorld/ChainRules.jl/test/global_state.jl:25
  Expression: false
ERROR: LoadError: There was an error during testing
in expression starting at /home/oxinabox/JuliaEnvs/ChainRulesWorld/ChainRules.jl/test/global_state.jl:14

This PR will fail until #562 is merged. We should merge one of these then rebase the other

@github-actions github-actions bot added the needs version bump Version needs to be incremented or set to -DEV in Project.toml label Jan 13, 2022
Copy link
Member

@mzgubic mzgubic left a comment

Choose a reason for hiding this comment

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

Adding this test here will ensure that no such rule is added to ChainRules, but users writing their own rules could still break things for themselves. It might be helpful to add this to CRTU instead/as well?

end

if function_type == DataType || function_type == UnionAll || function_type == Union
@error "Bad constructor rrule. typeof(T)` not `Type{T}`" method
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@error "Bad constructor rrule. typeof(T)` not `Type{T}`" method
@error "Bad constructor rrule. Use `Type{T}` not `typeof(T)`" method

Copy link
Member

Choose a reason for hiding this comment

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

Or Type{<:T} probably?

@oxinabox
Copy link
Member Author

Adding this test here will ensure that no such rule is added to ChainRules, but users writing their own rules could still break things for themselves. It might be helpful to add this to CRTU instead/as well?

Yeah, I guess we can put this into a function in CRTU and then just call it here

@mcabbott
Copy link
Member

Maybe test_rrule could check which(rrule, args...)? If I understand this version right, it'll complain that something is broken, but won't tell you which rule. Perhaps ideally you want both, since the presence of such a rule (even if it never meets test_rrule) is a global problem.

test/runtests.jl Outdated Show resolved Hide resolved
@oxinabox oxinabox merged commit d0b8d92 into main Jan 26, 2022
@oxinabox oxinabox deleted the ox/baddefcheck branch January 26, 2022 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs version bump Version needs to be incremented or set to -DEV in Project.toml
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants