Skip to content

Fix type piracy in demo tests - #22

Merged
devmotion merged 5 commits into
mainfrom
dmw/fix-demo-piracy
Oct 16, 2026
Merged

devmotion merged 5 commits into
mainfrom
dmw/fix-demo-piracy

Conversation

@devmotion

@devmotion devmotion commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

The demos in test/demos generated overloads such as (op::typeof(-))(::Vararg{Union{Dual,Float64},2}). These also match calls with only Float64 arguments, so they pirate e.g. -(::Float64, ::Float64). This is ambiguous with Base's methods, and the demo tests error with MethodError: -(::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

  • The demos now generate one method per position of the first Dual/Tracked argument. 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.md gets a short note on avoiding this pitfall in generated overloads.
  • Update GitHub Actions to their latest versions, so CI runs again. GitHub refuses workflows that use actions/cache@v2. Changes: actions/checkout v2 → v7, julia-actions/setup-julia v1 → v3, actions/cache v2 → v6, julia-buildpkg/julia-runtest @latest → @v1, and codecov/codecov-action v1 → v7 (with file: → files:).
  • CI uses native Julia binaries (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

devmotion and others added 2 commits October 16, 2026 14:57
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>
devmotion and others added 3 commits October 16, 2026 15:59
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>
@devmotion
devmotion merged commit f57a7ca into main Oct 16, 2026
12 checks passed
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.

1 participant