rlang icon indicating copy to clipboard operation
rlang copied to clipboard

`arg_match()` behavior when `arg` is too long

Open eutwt opened this issue 3 months ago • 0 comments

match_parent <- function(x) {
  rlang::arg_match(x, c("a", "b"))
}
match0_parent <- function(x) {
  rlang::arg_match0(x, c("a", "b"))
}

match0_parent(c("a", "b", "a"))
#> Error in `rlang::arg_match0()`:
#> ! `arg` must be a string or have the same length as `values`.

match_parent(c("a", "b", "c"))
#> Error in `match_parent()`:
#> ! `x` must be one of "a" or "b", not "a".
match_parent(c("a", "b", "a"))
#> [1] "a"

Created on 2025-10-13 with reprex v2.1.1

I would expect the match_parent() calls to give an error similar to the error produced by match0_parent()

eutwt avatar Oct 13 '25 19:10 eutwt