vctrs
vctrs copied to clipboard
`vec_as_subscript2()` has a misleading error when given logical input with `logical = "cast"`
Look at the first message:
Subscript has the wrong type
logical
.
It must be logical, numeric, or character.
library(vctrs)
vec_as_subscript2(TRUE, logical = "cast")
#> Error:
#> ! Must extract element with a single valid subscript.
#> ✖ Subscript has the wrong type `logical`.
#> ℹ It must be logical, numeric, or character.
vec_as_subscript2(TRUE, logical = "error")
#> Error:
#> ! Must extract element with a single valid subscript.
#> ✖ Subscript has the wrong type `logical`.
#> ℹ It must be numeric or character.
Also, why do we even expose a logical
argument? Shouldn't it always be error? We internally error right before exiting if we have a logical argument.
Also, why do we even expose a logical argument?
I don't remember. Maybe to follow base which coerces to integer?
letters[[TRUE]]
#> [1] "a"
Since this never worked correctly, let's just keep it an error and remove the argument.
The only two usages on CRAN are in tidyselect and in tibble, and both packages set logical = "error"
.