-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavior
Description
I was surprised to find that the ext argument of fs::path is not vectorized, as demonstrated in the below example:
library(fs)
library(assertthat)
bad_paths <- path("foo", letters[1:3], ext = c("txt1", "txt2", "txt3"))
correct_paths <- paste0("foo/", letters[1:3], ".txt", 1:3)
assert_that(all(bad_paths == correct_paths))
#> Error: Elements 2, 3 of bad_paths == correct_paths are not trueCreated on 2025-07-20 with reprex v2.1.1
The function silently takes the first element of ext and uses it for all elements, which leads to unexpected behavior. Either the argument should be modified to accept a vector rather than a scalar, or if not being vectorized is intentional, then it should at least throw an error when passed a vector with length != 1, and this fact should be documented in the help text.
gaborcsardi
Metadata
Metadata
Assignees
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavior