Repository navigation
Fix type piracy in demo tests - #22
Merged
Merged
Conversation
The demos generated overloads such as
`(op::typeof(-))(::Vararg{Union{Dual,Float64},2})`, which also match calls
with only `Float64` arguments. This pirates e.g. `-(::Float64, ::Float64)`
and is ambiguous with Base's methods, so the demo tests error with
`MethodError: -(::Float64, ::Float64) is ambiguous`. For functions without
arguments, the same code also overwrote ChainRulesCore's `_usethunks()`.
Now one method is generated per position of the first `Dual`/`Tracked`
argument, so every method requires at least one such argument and nothing
is defined for functions without arguments.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 tasks done
GitHub refuses to run workflows using `actions/cache@v2`. Also bump the other actions to supported versions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run Julia with the runner's native architecture instead of forcing x64. Julia 1.0 has no native Apple Silicon binaries, so it is no longer tested on macOS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The demos in
test/demosgenerated overloads such as(op::typeof(-))(::Vararg{Union{Dual,Float64},2}). These also match calls with onlyFloat64arguments, so they pirate e.g.-(::Float64, ::Float64). This is ambiguous with Base's methods, and the demo tests error withMethodError: -(::Float64, ::Float64) is ambiguous. That error is why the ChainRulesOverloadGeneration job in ChainRulesCore's integration tests fails. For functions without arguments, the same code also overwrote ChainRulesCore's_usethunks().Changes
Dual/Trackedargument. Every method requires at least one such argument, and nothing is defined for functions without arguments. N methods (for N arguments) is the minimum: a single signature that accepts both(Dual, Float64)and(Float64, Dual)also accepts(Float64, Float64).docs/src/index.mdgets a short note on avoiding this pitfall in generated overloads.actions/cache@v2. Changes:actions/checkoutv2 → v7,julia-actions/setup-juliav1 → v3,actions/cachev2 → v6,julia-buildpkg/julia-runtest@latest→@v1, andcodecov/codecov-actionv1 → v7 (withfile:→files:).arch: default) instead of forcing x64. Julia 1.0 has no native Apple Silicon build, so on macOS it runs on an Intel runner (macos-15-intel). The Julia versions are unchanged.Supersedes #14 (which worked around the ambiguities by pirating
Base.:(+)(::Float64, ::Float64)etc.) and the Dependabot PRs #16, #19 and #20.Testing
Tests pass locally (30/30) on Julia 1.10.12 and 1.13.1, using ChainRulesCore from JuliaDiff/ChainRulesCore.jl#715. Before this change they error on both versions.
🤖 Generated with Claude Code