Skip to content

arg_match() behavior when arg is too long #1838

@eutwt

Description

@eutwt
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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions