r-lib / rlang

Low-level API for programming with R
https://rlang.r-lib.org
Other
500 stars 137 forks source link

Can we align this `arg_match()` and `arg_match0()` error? #1569

Closed DavisVaughan closed 1 year ago

DavisVaughan commented 1 year ago
library(rlang)

fn <- function(x) {
  arg_match(x, values = c("a", "b"))
}
fn2 <- function(x) {
  arg_match0(x, values = c("a", "b"))
}

fn(1)
#> Error in `fn()`:
#> ! `x` must be a character vector, not the number 1.

fn2(1)
#> Error in `fn2()`:
#> ! `x` must be a string or character vector.

Looks like maybe the first one uses check_character()? This isn't a huge deal if its hard to do

lionel- commented 1 year ago

I agree this would be better aligned but this doesn't seem worth the changes.