fix: An empty argument slot with a name is not an ambiguous argument - #2850
Open
krlmlr wants to merge 1 commit into
Open
fix: An empty argument slot with a name is not an ambiguous argument#2850krlmlr wants to merge 1 commit into
krlmlr wants to merge 1 commit into
Conversation
```r as_adjacency_matrix(make_ring(4), a = ) ``` returns a 4x4 matrix on 2.3.3 and errors on the dev version with "Argument `a` matches multiple arguments of `as_adjacency_matrix()`". #2812 made the migration blocks handle empty slots by asking `base::missing()` inside `.old_signature()`, which is right and is what fixed the four #2646 revdeps. But two guards run *before* that closure is called, and both read argument names without looking at the values: * `.arg_ambiguous`, from `names(substitute(...()))`, rejects an abbreviation that could mean two different arguments; * `.arg_forbidden`, from `names(sys.call())`, rejects a tag that is a prefix of both a head formal and a recoverable one. An empty slot supplies nothing, so it cannot be ambiguous between two arguments and cannot conflict with a formal -- the old signature would have matched it by position and left the formal missing. Both guards now drop empty slots first. The empty slot is the empty symbol, which is a symbol whose name is the empty string; `Filter()` keeps the test to one expression, which matters because the block is `# fmt: skip` and every line of it is already long. Tests cover the shape on both fixtures that carry a guard -- `migration_fixture_shadow` for `.arg_ambiguous`, `migration_fixture_prefix` for `.arg_forbidden` -- which the empty-slot tests added by #2812 never touched, and assert that a *value* in the same slot is still rejected. One more test pins #2646's two reproducers verbatim against real migrated functions rather than the fixture. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D1xpHRV7yVfgtJg4vp9P7z
Contributor
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 8c47c15 is merged into main:
|
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.
main:Error: Argumentamatches multiple arguments ofas_adjacency_matrix().#2812 taught the migration blocks to handle empty slots by asking
base::missing()inside.old_signature()— which is right, and is what fixed the four #2646 revdeps. But two guards run before that closure is called, and both read argument names without ever looking at the values:.arg_ambiguous, fromnames(substitute(...())), rejects an abbreviation that could mean two different arguments — 20+ functions..arg_forbidden, fromnames(sys.call()), rejects a tag that is a prefix of both a head formal and a recoverable one.An empty slot supplies nothing, so it cannot be ambiguous between two arguments and cannot conflict with a formal. Under the old signature it matched by position and left the formal missing.
The change
Both guards drop empty slots before looking at names. The empty slot is the empty symbol — a symbol whose name is the empty string — and
Filter()keeps the test to one expression, which matters because the block is# fmt: skipand every line of it is already long:228 generated blocks, no line-count growth.
Verified against CRAN
mainas_adjacency_matrix(make_ring(4), a = )as_adjacency_matrix(make_ring(4), sparse = ,)as_adjacency_matrix(make_ring(4), )as_adjacency_matrix(make_ring(4), a = 1)The last row is the point: a value in the same slot is still rejected.
Tests
The empty-slot tests #2812 added only ever exercised
migration_fixture, which carries neither guard — which is exactly why this survived. New tests cover both fixtures that do:migration_fixture_shadowfor.arg_ambiguous,migration_fixture_prefixfor.arg_forbidden, each with the empty slot accepted and a value rejected (snapshotted).One more test pins #2646's two reproducers verbatim against real migrated functions rather than the fixture, plus the named-empty case on
as_adjacency_matrix().Full
testthat::test_local()green apart fromtest-foreign.R:69, which downloads fromgithub.com/igraph/graphsdb.Rscript tools/generate-migrations.Ris idempotent on the committed tree, so the CI drift check passes.🤖 Generated with Claude Code
https://claude.ai/code/session_01D1xpHRV7yVfgtJg4vp9P7z
Generated by Claude Code