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

deferred_run doesn't find attached handlers #257

Closed
dfalbel opened this issue Feb 29, 2024 · 1 comment
Closed

deferred_run doesn't find attached handlers #257

dfalbel opened this issue Feb 29, 2024 · 1 comment

Comments

@dfalbel
Copy link

dfalbel commented Feb 29, 2024

I wonder if this is the expected behavior of deferred_run:

env <- rlang::new_environment()

local_print <- function(path) {
  withr::defer(print("defered"), envir = env)
  attributes(env)
}

local({
  local_print()
})
#> NULL

withr::deferred_run(env)
#> No deferred expressions to run

I know that deferred_run is mostly inteded to run actions in the global environment:

The global environment scenario is the main motivation for these functions.

FWIW deferred_run() executes the deferred expression in withr 2.5

@lionel-
Copy link
Member

lionel- commented Feb 29, 2024

yep expected, it will only work if env is a frame environment currently on the call stack

@dfalbel dfalbel closed this as completed Feb 29, 2024
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

No branches or pull requests

2 participants