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 we add more context for Can't rename in this context errors? #336

Closed
DavisVaughan opened this issue Feb 22, 2023 · 2 comments · Fixed by #359
Closed

Can we add more context for Can't rename in this context errors? #336

DavisVaughan opened this issue Feb 22, 2023 · 2 comments · Fixed by #359

Comments

@DavisVaughan
Copy link
Member

This came up in tidyverse/dplyr#6745

We've started using allow_rename = FALSE more often when our interfaces use tidy selection purely for selection (i.e. when we don't allow named inputs for possible renaming), so this error has popped up more often.

I think it would be useful if we could mention the expression causing the issue, like how we do here:

library(tidyselect)
library(rlang)

eval_select(expr(all_of(x)), mtcars)
#> Error:
#> ! Problem while evaluating `all_of(x)`.
#> Caused by error in `as_indices_impl()`:
#> ! object 'x' not found

I'm imagining something like this for tidyverse/dplyr#6745:

#> Error in `rename_with()`:
#> ! Problem while evaluating `all_of(x)`.
#> ! Can't rename variables in this context.
@DavisVaughan
Copy link
Member Author

Another one tidyverse/tidyr#1481

@olivroy
Copy link
Contributor

olivroy commented Oct 25, 2024

@DavisVaughan I liked your suggestion in #358 (comment), but I didn't feel confident enough to implement it. If you have time, feel free to revisit!

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.

2 participants