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

on.exit() only called when iterator is exhausted #52

Open
hadley opened this issue Sep 11, 2024 · 0 comments
Open

on.exit() only called when iterator is exhausted #52

hadley opened this issue Sep 11, 2024 · 0 comments

Comments

@hadley
Copy link
Member

hadley commented Sep 11, 2024

g <- coro::generator(function() {
  on.exit(cat("** on.exit called\n"))
  yield(1)
  yield(2)
})

coro::loop(for (i in g()) {
})
#> ** on.exit called

coro::loop(for (i in g()) {
  stop("boom!")
})
#> Error in eval_bare(loop, env): boom!

coro::loop(for (i in g()) {
  break
})

Created on 2024-09-11 with reprex v2.1.0

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

1 participant