diff --git a/R/eval-walk.R b/R/eval-walk.R index e24470e..18070ef 100644 --- a/R/eval-walk.R +++ b/R/eval-walk.R @@ -87,21 +87,18 @@ ensure_named <- function(pos, if (!allow_rename && any(names2(pos) != "")) { if (is.null(error_arg)) { - cli::cli_abort( - "Can't rename variables in this context.", - class = "tidyselect_error_cannot_rename", - call = call - ) + i <- NULL } else { - cli::cli_abort( - c( - "Can't rename variables in this context.", - i = "{.arg {error_arg}} can't be renamed." - ), - class = "tidyselect_error_cannot_rename", - call = call - ) + i <- cli::format_inline("In argument: {.arg {error_arg}}.") } + abort( + c( + "Can't rename variables in this context.", + i = i + ), + class = "tidyselect_error_cannot_rename", + call = call + ) } nms <- names(pos) <- names2(pos) diff --git a/tests/testthat/_snaps/eval-relocate.md b/tests/testthat/_snaps/eval-relocate.md index ff2cba5..59d7eb6 100644 --- a/tests/testthat/_snaps/eval-relocate.md +++ b/tests/testthat/_snaps/eval-relocate.md @@ -75,7 +75,7 @@ Condition Error in `relocate_loc()`: ! Can't rename variables in this context. - i `...` can't be renamed. + i In argument: `...`. # can forbid empty selections diff --git a/tests/testthat/_snaps/eval-select.md b/tests/testthat/_snaps/eval-select.md index 9bf1582..69cb17e 100644 --- a/tests/testthat/_snaps/eval-select.md +++ b/tests/testthat/_snaps/eval-select.md @@ -45,7 +45,7 @@ Condition Error in `select_loc()`: ! Can't rename variables in this context. - i `x` can't be renamed. + i In argument: `x`. # can forbid empty selections