Providing `drop` in `[.vctrs_vctr` returns cryptic error message
From tidyverse/haven#698, originally from a Bioconductor bug report: https://support.bioconductor.org/p/9148139/
When the drop argument is provided while subsetting a vctrs vector it fails with error message Error in proxy[, ..., drop = FALSE]: incorrect number of dimensions, which is inconsistent with base R behaviour (where the drop argument is silently ignored for simple vectors). Minimal reprex below.
library(vctrs)
x_dbl <- 1
x_dbl[1, drop = FALSE]
#> [1] 1
x_vctr <- new_vctr(1, inherit_base_type = TRUE)
x_vctr[1, drop = FALSE]
#> Error in proxy[, ..., drop = FALSE]: incorrect number of dimensions
Created on 2022-12-06 with reprex v2.0.2
vec_index() is passing additional arguments to its own subsetting operation, which triggers the error since drop = FALSE is already set.
https://github.com/r-lib/vctrs/blob/1b9b22d96f34bb5c5155a24e422df2bbca407d94/R/slice.R#L210-L223
It'd be good if it behaved like base R in this case for compatibility (for e.g. with the linked Bioconductor stuff), potentially with a warning, or at least a clearer error message.
Thanks!