Skip to content

Preserve method argument expressions on R before 4.4 - #785

Merged
t-kalinowski merged 2 commits into
mainfrom
fix/method-error-calls
Oct 16, 2026
Merged

t-kalinowski merged 2 commits into
mainfrom
fix/method-error-calls

Conversation

@t-kalinowski

Copy link
Copy Markdown
Member

On R 4.2 and 4.3, deparsing the call recorded by a plain stop() inside an S7 method can fail with 'S4SXP': should not happen - please report. S7 now records the argument expressions, so an error from g(Foo()) has a readable call such as `method(g, Foo)`(x = Foo()). This also applies to warnings and sys.call() inside methods.

Internally, builds for R < 4.4 use applyClosure() to supply the original argument promises separately from the recorded call. This preserves laziness and substitute() behavior, including forwarded ... and super(). The compatibility code uses internal R APIs exposed by those older versions and is excluded from newer builds. R >= 4.4 retains the existing dispatcher. Public regressions cover argument expressions, promise behavior, and the version boundary.

Literal S7 values supplied through do.call() still encounter the older base-R deparser limitation; ordinary R functions fail in the same case.

Fixes #783.

Forward method arguments through dots so errors, warnings, and tracebacks
record symbolic calls without evaluating argument promises. This also avoids
the deparser failure on R 4.3.

Restore the generic's original dots on every exit, and match generic calls
in their caller's frame. Create dots nodes from a cached prototype to avoid
adding a dependency on a non-API allocator.
Use applyClosure() on R before 4.4 to forward the original promises while
recording their expressions in a separate method call. Restore the existing
dispatcher on newer R and cover errors, warnings, dots, and super().
@t-kalinowski
t-kalinowski marked this pull request as ready for review October 16, 2026 13:51
@t-kalinowski
t-kalinowski merged commit a84a354 into main Oct 16, 2026
15 checks passed
@t-kalinowski
t-kalinowski deleted the fix/method-error-calls branch October 16, 2026 13:51
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.

bug: deparse(conditionCall(cnd)) fails for errors raised in S7 methods

1 participant