Skip to content

Errors: store a call or NULL in cond$call#413

Merged
gaborcsardi merged 2 commits intomainfrom
fix/error-call
Apr 20, 2026
Merged

Errors: store a call or NULL in cond$call#413
gaborcsardi merged 2 commits intomainfrom
fix/error-call

Conversation

@gaborcsardi
Copy link
Copy Markdown
Member

Three changes in standalone-errors.R:

  1. Instead of storing the raw deparsed string in $call, re-parse it via str2lang() to produce a compact call object. For multiline calls that can't round-trip (e.g. withCallingHandlers({...})), the fallback is f(...) — the function head with ... as the sole argument. This keeps $call always a proper call object or NULL, so conditionCall() and rlang work correctly without any custom S3 method. Because rlang does not use conditionCall().

  2. frame_call() — replace the fragile delayedAssign()/sys.call() trick with a straightforward search.

  3. Format functions — use conditionCall(x) consistently instead of x[["call"]] directly, so the error header and trace formatting both go through the standard accessor.

Closes #360.

Three changes in `standalone-errors.R`:

1. Instead of storing the raw deparsed string in `$call`, re-parse
it via `str2lang()` to produce a compact call object. For multiline
calls that can't round-trip (e.g. `withCallingHandlers({...})`), the
fallback is `f(...)` — the function head with `...` as the sole argument.
This keeps `$call` always a proper call object or `NULL`, so
`conditionCall()` and rlang work correctly without any custom
S3 method. Because rlang does not use `conditionCall()`.

2. **`frame_call()`** — replace the fragile `delayedAssign()/sys.call()`
trick with a straightforward search.

3. **Format functions** — use `conditionCall(x)` consistently instead of
`x[["call"]]` directly, so the error header and trace formatting
both go through the standard accessor.

Closes #360.
@gaborcsardi gaborcsardi merged commit 2f68078 into main Apr 20, 2026
21 checks passed
@gaborcsardi gaborcsardi deleted the fix/error-call branch April 20, 2026 11:41
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.

$call should be a call or NULL in error objects

1 participant