Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't set rlang_trace_top_env for expected errors #221

Closed
lionel- opened this issue Aug 28, 2024 · 0 comments · Fixed by #223
Closed

Can't set rlang_trace_top_env for expected errors #221

lionel- opened this issue Aug 28, 2024 · 0 comments · Fixed by #223

Comments

@lionel-
Copy link
Member

lionel- commented Aug 28, 2024

This affects testthat snapshots in particular, see what happens to rlang backtrace tests with dev evaluate:

https://github.com/r-lib/rlang/compare/tmp/evaluate-snapshots?expand=1

I don't see a way of accommodating rlang_trace_top_env with the new evaluation setup. Possible solutions:

  1. Revert the new evaluation scheme and give up on on.exit.

  2. Add an option to trim rlang backtraces to evaluate(), following the approach discussed in Regression with last_error() in knitr #220:

    • Insert a dummy frame on the stack to serve as sentinel
    • Add a variant of rlang_trace_top_env on rlang that indicates the parent of the top env. This would be set to the dummy frame.

    If this new argument if off by default, this not only requires a release of rlang prior to releasing evaluate, but also releases of knitr and testthat once evaluate is on CRAN to use the new argument. But we can probably make it the default.

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 a pull request may close this issue.

1 participant