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

allow_rename = FALSE still allows renaming with partially renamed selections #305

Closed
DavisVaughan opened this issue Aug 26, 2022 · 1 comment · Fixed by #308
Closed

allow_rename = FALSE still allows renaming with partially renamed selections #305

DavisVaughan opened this issue Aug 26, 2022 · 1 comment · Fixed by #308
Labels
bug an unexpected problem or unintended behavior

Comments

@DavisVaughan
Copy link
Member

library(rlang)
library(tidyselect)

eval_select(expr(c(foo = mpg, bar = cyl)), mtcars, allow_rename = FALSE)
#> Error:
#> ! Can't rename variables in this context.

# uh oh
eval_select(expr(c(foo = mpg, cyl)), mtcars, allow_rename = FALSE)
#> foo cyl 
#>   1   2

Created on 2022-08-26 by the reprex package (v2.0.1)

@DavisVaughan DavisVaughan added the bug an unexpected problem or unintended behavior label Aug 26, 2022
@DavisVaughan
Copy link
Member Author

DavisVaughan commented Aug 26, 2022

Is the if statement here

tidyselect/R/eval-walk.R

Lines 106 to 112 in 8a44001

if (is_named(pos) && !is_empty(pos)) {
cli::cli_abort(
"Can't rename variables in this context.",
class = "tidyselect:::error_disallowed_rename",
call = call
)
}

supposed to be:

if (any(names2(pos) != ""))

?

is_named() returns TRUE if all of the elements are named, which isn't what we want here

lionel- added a commit that referenced this issue Aug 30, 2022
lionel- added a commit that referenced this issue Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant