From 9f75fb9d6b89436d4fde7da6ee00897cebd47093 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Fri, 25 Oct 2024 12:39:04 +0200 Subject: [PATCH] More accurate comment --- NEWS.md | 1 + R/eval-walk.R | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index 69a42e5..16fc26d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # tidyselect (development version) * `matches()` now uses `perl = TRUE` by default. This makes it more consitent with regular expressions in stringr (#330). + * `eval_select()` now fails when data has duplicate names and a character vector is provided as input (#346). * `eval_select()` and `eval_relocate()` gain a new `error_arg` argument that can be specified to throw a better error message when `allow_empty = FALSE` or `allow_rename = FALSE` (@olivroy, #327). diff --git a/R/eval-walk.R b/R/eval-walk.R index 98f0f2e..bed5ff1 100644 --- a/R/eval-walk.R +++ b/R/eval-walk.R @@ -323,13 +323,13 @@ eval_literal <- function(expr, data_mask, context_mask) { if (internal$uniquely_named && is_character(expr)) { # Since tidyselect allows repairing data frames with duplicate names by - # renaming positions, we can't check the input for duplicates. Instead, we - # check the output. But in case of character literals, checking the output - # doesn't work because we use `vctrs::vec_as_location()` to transform the - # strings to locations and it ignores duplicate names. So we instead check - # the input here, since it's not possible to repair duplicate names by - # matching them by name. This avoids an inconsistency with the symbolic - # path (#346). + # renaming or selecting positions, we can't check the input for duplicates. + # Instead, we check the output. But in case of character literals, checking + # the output doesn't work because we use `vctrs::vec_as_location()` to + # transform the strings to locations and it ignores duplicate names. So we + # instead check the input here, since it's not possible to repair duplicate + # names by matching them by name. This avoids an inconsistency with the + # symbolic path (#346). vctrs::vec_as_names( internal$vars, repair = "check_unique",