Skip to content

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

Closed
jjjermiah/S7
#2

Description

@jjjermiah

Errors raised inside an S7 method record a call that contains the dispatched S7 object.
On R 4.3.3 that call can't be deparsed, so any tool using conditionCall() crashes.

library(S7)

Foo <- new_class("Foo")
g <- new_generic("g", "x")
method(g, Foo) <- function(x) stop("boom")

cnd <- tryCatch(g(Foo()), error = identity)
deparse(conditionCall(cnd))
#> Error in deparse(conditionCall(cnd)) :
#>   'S4SXP': should not happen - please report

rlang::as_label(conditionCall(cnd)) fails the same way.
The call's head is the method(g, Foo) symbol. Its dispatch argument is a forced promise holding the S7 object it looks like
R-devel has a commit makes deparse() handle these objects, but released R versions still fail.

Could S7 record a call that succesfully deparses, without expecting updating to R-devel?

Session info ─ Session info ─────────────────────────────────────────────────────────────── setting value version R version 4.3.3 (2024-02-29) os macOS 27.0 system aarch64, darwin20 ui X11 language (EN) collate en_CA.UTF-8 ctype en_CA.UTF-8 tz America/Toronto date 2026-10-14

─ Packages ───────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
S7 * 0.2.2.9000 2026-10-14 [1] Github (426c13e)

Related: #318, which was closed as tracked in base R.

Activity

  1. t-kalinowski commented on Oct 14, 2026

    @t-kalinowski
    Member

    Thanks for opening this issue. You don’t need to switch to R-devel: this deparsing error was fixed in R 4.4.0, released in April 2024, over two years ago. Updating to R 4.4 or a later stable release should resolve it. If upgrading isn’t an option, we also have a draft S7 fix for R 4.2 and 4.3.

  2. jjjermiah commented on Oct 20, 2026

    @jjjermiah
    ContributorAuthor

    oh this is great thank you!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions