diff --git a/NAMESPACE b/NAMESPACE index e752736e0..989f60e38 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -110,9 +110,7 @@ S3method(cnd_header,vctrs_error_matches_remaining) S3method(cnd_header,vctrs_error_names_cannot_be_dot_dot) S3method(cnd_header,vctrs_error_names_cannot_be_empty) S3method(cnd_header,vctrs_error_names_must_be_unique) -S3method(cnd_header,vctrs_error_subscript_oob) -S3method(cnd_header,vctrs_error_subscript_size) -S3method(cnd_header,vctrs_error_subscript_type) +S3method(cnd_header,vctrs_error_subscript) S3method(diff,vctrs_vctr) S3method(duplicated,vctrs_sclr) S3method(duplicated,vctrs_vctr) diff --git a/R/subscript-loc.R b/R/subscript-loc.R index 53d7989c3..d078a9ec9 100644 --- a/R/subscript-loc.R +++ b/R/subscript-loc.R @@ -487,34 +487,12 @@ stop_subscript_oob <- function(i, ) } -#' @export -cnd_header.vctrs_error_subscript_oob <- function(cnd, ...) { - if (cnd_subscript_oob_non_consecutive(cnd)) { - return(cnd_header_vctrs_error_subscript_oob_non_consecutive(cnd, ...)) - } - - elt <- cnd_subscript_element(cnd) - action <- cnd_subscript_action(cnd) - type <- cnd_subscript_type(cnd) - - if (action %in% c("rename", "relocate") || type == "character") { - glue::glue("Can't {action} {elt[[2]]} that don't exist.") - } else { - glue::glue("Can't {action} {elt[[2]]} past the end.") - } -} - #' @export cnd_body.vctrs_error_subscript_oob <- function(cnd, ...) { - switch(cnd_subscript_type(cnd), - numeric = - if (cnd_subscript_oob_non_consecutive(cnd)) { - cnd_body_vctrs_error_subscript_oob_non_consecutive(cnd, ...) - } else { - cnd_body_vctrs_error_subscript_oob_location(cnd, ...) - }, - character = - cnd_body_vctrs_error_subscript_oob_name(cnd, ...), + switch( + cnd_subscript_type(cnd), + numeric = cnd_body_vctrs_error_subscript_oob_location(cnd, ...), + character = cnd_body_vctrs_error_subscript_oob_name(cnd, ...), abort("Internal error: subscript type can't be `logical` for OOB errors.") ) } @@ -533,28 +511,46 @@ cnd_body_vctrs_error_subscript_oob_location <- function(cnd, ...) { i <- abs(i) oob <- i[i > cnd$size] - oob_enum <- vctrs_cli_vec(oob) n_loc <- length(oob) n <- cnd$size elt <- cnd_subscript_element_cli(n, cnd) + allow_extension <- cnd_subscript_oob_non_consecutive(cnd) + scalar_oob <- length(oob) == 1 + + arg <- cnd_subscript_arg(cnd) + + if (scalar_oob) { + arg <- arg + not <- glue::glue(", not {oob}") + oob_line <- NULL + } else { + arg <- glue::glue("Locations in {arg}") + not <- "" + oob_enum <- vctrs_cli_vec(oob) + oob_line <- cli::format_inline("Larger locations: {oob_enum}") + } + # TODO: Switch to `format_inline()` and format bullets lazily through rlang cli::format_error(c( - "i" = "{cli::qty(n_loc)} Location{?s} {oob_enum} do{?esn't/n't} exist.", - "i" = "There {cli::qty(n)} {?is/are} only {elt}." + "x" = "{cli::qty(n_loc)} Location{?s} must be less than or equal to {n}{not}.", + "x" = oob_line, + "i" = "There {cli::qty(n)} {?is/are} only {elt}.", + "i" = if (allow_extension) "Extension with consecutive locations is allowed." )) } cnd_body_vctrs_error_subscript_oob_name <- function(cnd, ...) { - elt <- cnd_subscript_element(cnd, capital = TRUE) + elt <- cnd_subscript_element(cnd, capital = FALSE) + elt_cap <- cnd_subscript_element(cnd, capital = TRUE) oob <- cnd$i[!cnd$i %in% cnd$names] oob_enum <- enumerate(glue::backtick(oob)) format_error_bullets(c( x = glue::glue(ngettext( length(oob), - "{elt[[1]]} {oob_enum} doesn't exist.", - "{elt[[2]]} {oob_enum} don't exist." + "Can't find {elt[[1]]} {oob_enum}.", + "Can't find {elt[[2]]} {oob_enum}.", )) )) } @@ -577,32 +573,6 @@ stop_location_oob_non_consecutive <- function(i, ) } -cnd_header_vctrs_error_subscript_oob_non_consecutive <- function(cnd, ...) { - action <- cnd_subscript_action(cnd) - elt <- cnd_subscript_element(cnd) - glue::glue("Can't {action} {elt[[2]]} beyond the end with non-consecutive locations.") -} -cnd_body_vctrs_error_subscript_oob_non_consecutive <- function(cnd, ...) { - i <- sort(cnd$i) - i <- i[i > cnd$size] - - non_consecutive <- i[c(TRUE, diff(i) != 1L)] - - arg <- append_arg("Subscript", cnd$subscript_arg) - if (length(non_consecutive) == 1) { - x_line <- glue::glue("{arg} contains non-consecutive location {non_consecutive}.") - } else { - non_consecutive <- ensure_full_stop(enumerate(non_consecutive)) - x_line <- glue::glue("{arg} contains non-consecutive locations {non_consecutive}") - } - - glue_data_bullets( - cnd, - i = "Input has size {size}.", - x = x_line - ) -} - cnd_subscript_oob_non_consecutive <- function(cnd) { out <- cnd$subscript_oob_non_consecutive %||% FALSE check_bool(out) diff --git a/R/subscript.R b/R/subscript.R index e524a2f58..60b71bd15 100644 --- a/R/subscript.R +++ b/R/subscript.R @@ -174,7 +174,7 @@ new_error_subscript_type <- function(i, } #' @export -cnd_header.vctrs_error_subscript_type <- function(cnd) { +cnd_header.vctrs_error_subscript <- function(cnd) { arg <- cnd[["subscript_arg"]] if (is_subscript_arg(arg)) { with <- glue::glue(" with {format_subscript_arg(arg)}") @@ -233,10 +233,6 @@ new_error_subscript_size <- function(i, ... ) } -#' @export -cnd_header.vctrs_error_subscript_size <- function(cnd, ...) { - cnd_header.vctrs_error_subscript_type(cnd, ...) -} new_error_subscript2_type <- function(i, numeric, diff --git a/tests/testthat/_snaps/conditions.md b/tests/testthat/_snaps/conditions.md index 921b36990..9585cc890 100644 --- a/tests/testthat/_snaps/conditions.md +++ b/tests/testthat/_snaps/conditions.md @@ -22,24 +22,24 @@ Output Error in `vec_slice()`: - ! Can't subset elements that don't exist. - x Element `foo` doesn't exist. + ! Can't subset elements. + x Can't find element `foo`. Code (expect_error(with_subscript_data(vec_slice(set_names(letters), "foo"), quote( foo)), class = "vctrs_error_subscript_oob")) Output Error in `vec_slice()`: - ! Can't subset elements that don't exist. - x Element `foo` doesn't exist. + ! Can't subset elements with `foo`. + x Can't find element `foo`. Code (expect_error(with_subscript_data(vec_slice(set_names(letters), "foo"), quote( foo(bar))), class = "vctrs_error_subscript_oob")) Output Error in `vec_slice()`: - ! Can't subset elements that don't exist. - x Element `foo` doesn't exist. + ! Can't subset elements with `foo(bar)`. + x Can't find element `foo`. # scalar type errors are informative diff --git a/tests/testthat/_snaps/error-call.md b/tests/testthat/_snaps/error-call.md index 9fa9ddc08..120232bab 100644 --- a/tests/testthat/_snaps/error-call.md +++ b/tests/testthat/_snaps/error-call.md @@ -207,8 +207,8 @@ Output Error in `my_function()`: - ! Can't subset elements past the end. - i Location 10 doesn't exist. + ! Can't subset elements with `10`. + x Location must be less than or equal to 2, not 10. i There are only 2 elements. --- diff --git a/tests/testthat/_snaps/slice-assign.md b/tests/testthat/_snaps/slice-assign.md index 93eebb30e..521224451 100644 --- a/tests/testthat/_snaps/slice-assign.md +++ b/tests/testthat/_snaps/slice-assign.md @@ -37,8 +37,8 @@ Output Error: - ! Can't assign to elements past the end. - i Location 5 doesn't exist. + ! Can't assign elements. + x Location must be less than or equal to 3, not 5. i There are only 3 elements. Code (expect_error(vec_assign(1:3, "foo", 10), "unnamed vector")) @@ -52,8 +52,8 @@ Output Error: - ! Can't negate elements past the end. - i Location 100 doesn't exist. + ! Can't negate elements. + x Location must be less than or equal to 26, not 100. i There are only 26 elements. Code (expect_error(vec_assign(set_names(letters), "foo", "bar"), class = "vctrs_error_subscript_oob") @@ -61,8 +61,8 @@ Output Error: - ! Can't assign to elements that don't exist. - x Element `foo` doesn't exist. + ! Can't assign elements. + x Can't find element `foo`. # must assign with proper negative locations diff --git a/tests/testthat/_snaps/slice-chop.md b/tests/testthat/_snaps/slice-chop.md index f79e057c2..7eb939495 100644 --- a/tests/testthat/_snaps/slice-chop.md +++ b/tests/testthat/_snaps/slice-chop.md @@ -227,8 +227,8 @@ Output Error: - ! Can't subset elements past the end. - i Location 3 doesn't exist. + ! Can't subset elements. + x Location must be less than or equal to 2, not 3. i There are only 2 elements. --- diff --git a/tests/testthat/_snaps/slice.md b/tests/testthat/_snaps/slice.md index ef493a9a2..a9d364f4e 100644 --- a/tests/testthat/_snaps/slice.md +++ b/tests/testthat/_snaps/slice.md @@ -23,16 +23,16 @@ Output Error in `vec_slice()`: - ! Can't subset elements past the end. - i Location 3 doesn't exist. + ! Can't subset elements with `i`. + x Location must be less than or equal to 2, not 3. i There are only 2 elements. Code (expect_error(vec_slice(1:2, -3L), class = "vctrs_error_subscript_oob")) Output Error in `vec_slice()`: - ! Can't negate elements past the end. - i Location 3 doesn't exist. + ! Can't negate elements with `i`. + x Location must be less than or equal to 2, not 3. i There are only 2 elements. # can slice with double indices @@ -79,8 +79,8 @@ vec_slice(c(bar = 1), "foo") Condition Error in `vec_slice()`: - ! Can't subset elements that don't exist. - x Element `foo` doesn't exist. + ! Can't subset elements with `i`. + x Can't find element `foo`. --- @@ -88,8 +88,9 @@ vec_slice(letters, c(100, 1000)) Condition Error in `vec_slice()`: - ! Can't subset elements past the end. - i Locations 100 and 1000 don't exist. + ! Can't subset elements with `i`. + x Locations must be less than or equal to 26. + x Larger locations: 100 and 1000 i There are only 26 elements. --- @@ -98,8 +99,9 @@ vec_slice(letters, c(1, 100:103, 2, 104:110)) Condition Error in `vec_slice()`: - ! Can't subset elements past the end. - i Locations 100, 101, 102, ..., 109, and 110 don't exist. + ! Can't subset elements with `i`. + x Locations must be less than or equal to 26. + x Larger locations: 100, 101, 102, ..., 109, and 110 i There are only 26 elements. --- @@ -108,8 +110,8 @@ vec_slice(set_names(letters), c("foo", "bar")) Condition Error in `vec_slice()`: - ! Can't subset elements that don't exist. - x Elements `foo` and `bar` don't exist. + ! Can't subset elements with `i`. + x Can't find elements `foo` and `bar`. --- @@ -117,8 +119,8 @@ vec_slice(set_names(letters), toupper(letters)) Condition Error in `vec_slice()`: - ! Can't subset elements that don't exist. - x Elements `A`, `B`, `C`, `D`, `E`, etc. don't exist. + ! Can't subset elements with `i`. + x Can't find elements `A`, `B`, `C`, `D`, `E`, etc.. # vec_init() validates `n` diff --git a/tests/testthat/_snaps/subscript-loc.md b/tests/testthat/_snaps/subscript-loc.md index e1f40b9f0..35dabb469 100644 --- a/tests/testthat/_snaps/subscript-loc.md +++ b/tests/testthat/_snaps/subscript-loc.md @@ -171,24 +171,24 @@ Output Error: - ! Can't subset elements past the end. - i Location 10 doesn't exist. + ! Can't subset elements with `10L`. + x Location must be less than or equal to 2, not 10. i There are only 2 elements. Code (expect_error(vec_as_location(-10L, 2L), class = "vctrs_error_subscript_oob")) Output Error: - ! Can't negate elements past the end. - i Location 10 doesn't exist. + ! Can't negate elements with `-10L`. + x Location must be less than or equal to 2, not 10. i There are only 2 elements. Code (expect_error(vec_as_location2(10L, 2L), class = "vctrs_error_subscript_oob")) Output Error: - ! Can't extract elements past the end. - i Location 10 doesn't exist. + ! Can't extract element with `10L`. + x Location must be less than or equal to 2, not 10. i There are only 2 elements. Code # Character indexing @@ -197,24 +197,24 @@ Output Error: - ! Can't subset elements that don't exist. - x Element `foo` doesn't exist. + ! Can't subset elements with `"foo"`. + x Can't find element `foo`. Code (expect_error(vec_as_location2("foo", 1L, names = "bar"), class = "vctrs_error_subscript_oob") ) Output Error: - ! Can't extract elements that don't exist. - x Element `foo` doesn't exist. + ! Can't extract element with `"foo"`. + x Can't find element `foo`. Code (expect_error(vec_as_location2("foo", 1L, names = "bar", call = call("baz")), class = "vctrs_error_subscript_oob")) Output Error in `baz()`: - ! Can't extract elements that don't exist. - x Element `foo` doesn't exist. + ! Can't extract element with `"foo"`. + x Can't find element `foo`. # vec_as_location2() requires length 1 inputs @@ -415,45 +415,53 @@ Output Error: - ! Can't subset elements beyond the end with non-consecutive locations. - i Input has size 1. - x Subscript `3` contains non-consecutive location 3. + ! Can't subset elements with `3`. + x Location must be less than or equal to 1, not 3. + i There is only 1 element. + i Extension with consecutive locations is allowed. Code (expect_error(num_as_location(c(1, 3), 1, oob = "extend"), class = "vctrs_error_subscript_oob") ) Output Error: - ! Can't subset elements beyond the end with non-consecutive locations. - i Input has size 1. - x Subscript `c(1, 3)` contains non-consecutive location 3. + ! Can't subset elements with `c(1, 3)`. + x Location must be less than or equal to 1, not 3. + i There is only 1 element. + i Extension with consecutive locations is allowed. Code (expect_error(num_as_location(c(1:5, 7), 3, oob = "extend"), class = "vctrs_error_subscript_oob") ) Output Error: - ! Can't subset elements beyond the end with non-consecutive locations. - i Input has size 3. - x Subscript `c(1:5, 7)` contains non-consecutive locations 4 and 7. + ! Can't subset elements with `c(1:5, 7)`. + x Locations must be less than or equal to 3. + x Larger locations: 4, 5, and 7 + i There are only 3 elements. + i Extension with consecutive locations is allowed. Code (expect_error(num_as_location(c(1:5, 7, 1), 3, oob = "extend"), class = "vctrs_error_subscript_oob") ) Output Error: - ! Can't subset elements beyond the end with non-consecutive locations. - i Input has size 3. - x Subscript `c(1:5, 7, 1)` contains non-consecutive locations 4 and 7. + ! Can't subset elements with `c(1:5, 7, 1)`. + x Locations must be less than or equal to 3. + x Larger locations: 4, 5, and 7 + i There are only 3 elements. + i Extension with consecutive locations is allowed. Code (expect_error(class = "vctrs_error_subscript_oob", num_as_location(c(1:5, 7, 1, 10), 3, oob = "extend"))) Output Error: - ! Can't subset elements beyond the end with non-consecutive locations. - i Input has size 3. - x Subscript `c(1:5, 7, 1, 10)` contains non-consecutive locations 4, 7, and 10. + ! Can't subset elements with `c(1:5, 7, 1, 10)`. + x Locations must be less than or equal to 3. + x Larger locations: 4, 5, 7, and 10 + i There are only 3 elements. + i Extension with consecutive locations is allowed. # num_as_location() errors when inverting oob negatives unless `oob = 'remove'` (#1630) @@ -461,8 +469,8 @@ num_as_location(-4, 3, oob = "error", negative = "invert") Condition Error: - ! Can't negate elements past the end. - i Location 4 doesn't exist. + ! Can't negate elements with `-4`. + x Location must be less than or equal to 3, not 4. i There are only 3 elements. --- @@ -471,8 +479,8 @@ num_as_location(c(-4, 4, 5), 3, oob = "extend", negative = "invert") Condition Error: - ! Can't negate elements past the end. - i Location 4 doesn't exist. + ! Can't negate elements with `c(-4, 4, 5)`. + x Location must be less than or equal to 3, not 4. i There are only 3 elements. # num_as_location() errors on disallowed zeros when inverting negatives (#1612) @@ -501,8 +509,8 @@ num_as_location(-6L, 5L, oob = "extend", negative = "ignore") Condition Error: - ! Can't negate elements past the end. - i Location 6 doesn't exist. + ! Can't negate elements with `-6L`. + x Location must be less than or equal to 5, not 6. i There are only 5 elements. --- @@ -511,8 +519,8 @@ num_as_location(c(-7L, 6L), 5L, oob = "extend", negative = "ignore") Condition Error: - ! Can't negate elements past the end. - i Location 7 doesn't exist. + ! Can't negate elements with `c(-7L, 6L)`. + x Location must be less than or equal to 5, not 7. i There are only 5 elements. --- @@ -521,8 +529,8 @@ num_as_location(c(-7L, NA), 5L, oob = "extend", negative = "ignore") Condition Error: - ! Can't negate elements past the end. - i Location 7 doesn't exist. + ! Can't negate elements with `c(-7L, NA)`. + x Location must be less than or equal to 5, not 7. i There are only 5 elements. # num_as_location() with `oob = 'error'` reports negative and positive oob values @@ -531,8 +539,9 @@ num_as_location(c(-6L, 7L), n = 5L, oob = "error", negative = "ignore") Condition Error: - ! Can't subset elements past the end. - i Locations 6 and 7 don't exist. + ! Can't subset elements with `c(-6L, 7L)`. + x Locations must be less than or equal to 5. + x Larger locations: 6 and 7 i There are only 5 elements. # missing values are supported in error formatters @@ -543,8 +552,9 @@ Output Error: - ! Can't subset elements past the end. - i Locations 2 and 3 don't exist. + ! Can't subset elements with `c(1, NA, 2, 3)`. + x Locations must be less than or equal to 1. + x Larger locations: 2 and 3 i There is only 1 element. Code (expect_error(num_as_location(c(1, NA, 3), 1, oob = "extend"), class = "vctrs_error_subscript_oob") @@ -552,9 +562,10 @@ Output Error: - ! Can't subset elements beyond the end with non-consecutive locations. - i Input has size 1. - x Subscript `c(1, NA, 3)` contains non-consecutive location 3. + ! Can't subset elements with `c(1, NA, 3)`. + x Location must be less than or equal to 1, not 3. + i There is only 1 element. + i Extension with consecutive locations is allowed. # can disallow missing values @@ -777,9 +788,10 @@ Output Error in `my_function()`: - ! Can't subset elements beyond the end with non-consecutive locations. - i Input has size 2. - x Subscript `foo` contains non-consecutive location 4. + ! Can't subset elements with `foo`. + x Location must be less than or equal to 2, not 4. + i There are only 2 elements. + i Extension with consecutive locations is allowed. Code (expect_error(num_as_location(0, 1, zero = "error", arg = "foo", call = call( "my_function")), class = "vctrs_error_subscript_type")) @@ -862,9 +874,10 @@ Output Error: - ! Can't rename columns beyond the end with non-consecutive locations. - i Input has size 2. - x Subscript `foo(bar)` contains non-consecutive location 4. + ! Can't rename columns with `foo(bar)`. + x Location must be less than or equal to 2, not 4. + i There are only 2 columns. + i Extension with consecutive locations is allowed. Code (expect_error(with_tibble_cols(num_as_location(0, 1, zero = "error")), class = "vctrs_error_subscript_type") ) @@ -883,8 +896,8 @@ Output Error in `vec_slice()`: - ! Can't subset elements that don't exist. - x Element `foo` doesn't exist. + ! Can't subset elements with `i`. + x Can't find element `foo`. Code # With custom `arg` (expect_error(vec_as_location(30, length(letters), arg = "foo", call = call( @@ -892,8 +905,8 @@ Output Error in `my_function()`: - ! Can't subset elements past the end. - i Location 30 doesn't exist. + ! Can't subset elements with `foo`. + x Location must be less than or equal to 26, not 30. i There are only 26 elements. Code (expect_error(vec_as_location("foo", NULL, letters, arg = "foo", call = call( @@ -901,8 +914,8 @@ Output Error in `my_function()`: - ! Can't subset elements that don't exist. - x Element `foo` doesn't exist. + ! Can't subset elements with `foo`. + x Can't find element `foo`. Code # With tibble columns (expect_error(with_tibble_cols(vec_slice(set_names(letters), "foo")), class = "vctrs_error_subscript_oob") @@ -910,16 +923,16 @@ Output Error in `vec_slice()`: - ! Can't rename columns that don't exist. - x Column `foo` doesn't exist. + ! Can't rename columns with `foo(bar)`. + x Can't find column `foo`. Code (expect_error(with_tibble_cols(vec_slice(set_names(letters), 30)), class = "vctrs_error_subscript_oob") ) Output Error in `vec_slice()`: - ! Can't rename columns that don't exist. - i Location 30 doesn't exist. + ! Can't rename columns with `foo(bar)`. + x Location must be less than or equal to 26, not 30. i There are only 26 columns. Code (expect_error(with_tibble_cols(vec_slice(set_names(letters), -30)), class = "vctrs_error_subscript_oob") @@ -927,8 +940,8 @@ Output Error in `vec_slice()`: - ! Can't rename columns that don't exist. - i Location 30 doesn't exist. + ! Can't rename columns with `foo(bar)`. + x Location must be less than or equal to 26, not 30. i There are only 26 columns. Code # With tibble rows @@ -937,16 +950,17 @@ Output Error in `vec_slice()`: - ! Can't remove rows that don't exist. - x Rows `foo` and `bar` don't exist. + ! Can't remove rows with `foo(bar)`. + x Can't find rows `foo` and `bar`. Code (expect_error(with_tibble_rows(vec_slice(set_names(letters), 1:30)), class = "vctrs_error_subscript_oob") ) Output Error in `vec_slice()`: - ! Can't remove rows past the end. - i Locations 27, 28, 29, and 30 don't exist. + ! Can't remove rows with `foo(bar)`. + x Locations must be less than or equal to 26. + x Larger locations: 27, 28, 29, and 30 i There are only 26 rows. Code (expect_error(with_tibble_rows(vec_slice(set_names(letters), -(1:30))), class = "vctrs_error_subscript_oob") @@ -954,8 +968,9 @@ Output Error in `vec_slice()`: - ! Can't remove rows past the end. - i Locations 27, 28, 29, and 30 don't exist. + ! Can't remove rows with `foo(bar)`. + x Locations must be less than or equal to 26. + x Larger locations: 27, 28, 29, and 30 i There are only 26 rows. Code # With tidyselect select @@ -964,16 +979,16 @@ Output Error in `vec_slice()`: - ! Can't select columns that don't exist. - x Columns `foo` and `bar` don't exist. + ! Can't select columns with `foo(bar)`. + x Can't find columns `foo` and `bar`. Code (expect_error(with_tidyselect_select(vec_slice(set_names(letters), 30)), class = "vctrs_error_subscript_oob") ) Output Error in `vec_slice()`: - ! Can't select columns past the end. - i Location 30 doesn't exist. + ! Can't select columns with `foo(bar)`. + x Location must be less than or equal to 26, not 30. i There are only 26 columns. Code (expect_error(with_tidyselect_select(vec_slice(set_names(letters), -(1:30))), @@ -981,8 +996,9 @@ Output Error in `vec_slice()`: - ! Can't select columns past the end. - i Locations 27, 28, 29, and 30 don't exist. + ! Can't select columns with `foo(bar)`. + x Locations must be less than or equal to 26. + x Larger locations: 27, 28, 29, and 30 i There are only 26 columns. Code # With tidyselect relocate @@ -991,16 +1007,16 @@ Output Error in `vec_slice()`: - ! Can't relocate columns that don't exist. - x Columns `foo` and `bar` don't exist. + ! Can't relocate columns with `foo(bar)`. + x Can't find columns `foo` and `bar`. Code (expect_error(with_tidyselect_relocate(vec_slice(set_names(letters), 30)), class = "vctrs_error_subscript_oob")) Output Error in `vec_slice()`: - ! Can't relocate columns that don't exist. - i Location 30 doesn't exist. + ! Can't relocate columns with `foo(bar)`. + x Location must be less than or equal to 26, not 30. i There are only 26 columns. Code (expect_error(with_tidyselect_relocate(vec_slice(set_names(letters), -(1:30))), @@ -1008,8 +1024,9 @@ Output Error in `vec_slice()`: - ! Can't relocate columns that don't exist. - i Locations 27, 28, 29, and 30 don't exist. + ! Can't relocate columns with `foo(bar)`. + x Locations must be less than or equal to 26. + x Larger locations: 27, 28, 29, and 30 i There are only 26 columns. # vec_as_location() checks dimensionality