Repository navigation
Conversation
The method call recorded by S7_dispatch() held the dispatch arguments as forced promises. deparse(conditionCall(cnd)) and rlang::as_label() force those promises and then fail on released versions of R with "'S4SXP': should not happen", because the promise value is an S7 object. Collect the arguments into a `...` (a DOTSXP, so tags and promises are kept and substitute() still sees the original expressions) and call the method as `method(generic, Class)`(...). The method is still evaluated in the generic's frame, with the generic's own `...` restored afterwards. Tracebacks no longer show argument values.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…tium#783) Routing every argument through `...` made tracebacks lose argument values. Only a forced S7 value (an OBJSXP without the S4 bit) breaks deparse(), so route just those, and keep every other argument in the recorded call as on main. If nothing needs routing, dispatch is unchanged and skips the dispatch_dots() call. Non-dispatch arguments are not forced to check, so one holding an S7 object still breaks deparse().
Owner
Author
|
Closing this fork draft. RConsortium#785 merged the fix for the R 4.2/4.3 method-call deparse bug, and upstream issue RConsortium#783 is closed. Modern R already deparses the call. Keeping a second, divergent fork implementation open would add no path to shipping the fix. |
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.
Fixes RConsortium#783.
Errors raised in an S7 method record a call that holds the dispatched promises. When a dispatch argument is an S7 object,
deparse()on released R forces the promise and fails:Only an already-forced S7 value (an
OBJSXPwithout the S4 bit) breaksdeparse(). Somethod_call_()now leaves every other argument in the recorded call exactly as before, and routes only those values through.... The call deparses on any R version, and existing tracebacks are unchanged:How it works:
...of a frame, so the C code calls a smalldispatch_dots <- function(...) environment()with them, plus the generic's own..., and takes its....parent.frame()doesn't change. The generic's own...is swapped for the new one during the call and restored withR_ExecWithCleanup(), including on error.substitute(),missing(),nargs()andmatch.call()behave as before. New tests pin these, and they also pass on main....swap.Trade-offs:
g3(Foo(), Foo(), z = Foo())withznot used for dispatch) still breaksdeparse(). Checking would mean forcing the promise, which main never does.Tested on R 4.3.3: the full suite passes (2018 expectations, previously 1996), the existing traceback snapshots are untouched, and
R CMD check --no-manualis OK. Not yet run on newer R or with the R-devel non-API checks.