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

Improve eval_select() error chaining #352

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

olivroy
Copy link

@olivroy olivroy commented Jul 11, 2024

I noticed that there was an issue with backtraces. Turns out a simple forgotten error call caused it.

# before
library(tidyselect)
f <- function(expr, call = rlang::caller_env()) {
  eval_select(
    expr = {{ expr }},
    data = mtcars
  )
}
f(16)
#> Error in `vars_select_eval()`:
#> ! Can't select columns past the end.
#> ℹ Location 16 doesn't exist.
#> ℹ There are only 11 columns.

Created on 2024-07-11 with reprex v2.1.1

# this PR
devtools::load_all(".")
#> ℹ Loading tidyselect
f <- function(expr, call = rlang::caller_env()) {
  eval_select(
    expr = {{ expr }},
    data = mtcars
  )
}
f(16)
#> Error in `f()`:
#> ! Can't select columns past the end.
#> ℹ Location 16 doesn't exist.
#> ℹ There are only 11 columns.

Created on 2024-07-11 with reprex v2.1.1

I don't mind adding a test if you think it is worthwhile.


Upstream, I am working on gt.

Here is the nice effect this PR will have on gt when the next tidyselect version is released. (above is the new message, below is with CRAN tidyselect)
image

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.

1 participant