Skip to content

Commit 7f3e858

Browse files
committed
Always pass a string to cli_abort()
1 parent 55d0a98 commit 7f3e858

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

R/eval-walk.R

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,24 @@ ensure_named <- function(pos,
108108
error_arg = NULL,
109109
call = caller_env()) {
110110
check_empty(pos, allow_empty, error_arg, call = call)
111-
112111

113112
if (!allow_rename && any(names2(pos) != "")) {
114-
msg <- "Can't rename variables in this context."
115-
# Add more context if error_arg is supplied.
116-
if (!is.null(error_arg)) {
117-
msg <- c(msg, "i" = "{.arg {error_arg}} can't be renamed.")
113+
if (is.null(error_arg)) {
114+
cli::cli_abort(
115+
"Can't rename variables in this context.",
116+
class = "tidyselect:::error_disallowed_rename",
117+
call = call
118+
)
119+
} else {
120+
cli::cli_abort(
121+
c(
122+
"Can't rename variables in this context.",
123+
i = "{.arg {error_arg}} can't be renamed."
124+
),
125+
class = "tidyselect:::error_disallowed_rename",
126+
call = call
127+
)
118128
}
119-
cli::cli_abort(
120-
msg,
121-
class = "tidyselect:::error_disallowed_rename",
122-
call = call
123-
)
124129
}
125130

126131
nms <- names(pos) <- names2(pos)

0 commit comments

Comments
 (0)