Skip to content

vec_as_subscript2() doesn't throw lossy cast errors correctly #1606

@DavisVaughan

Description

@DavisVaughan
library(vctrs)

vec_as_subscript(1.5)
#> Error:
#> ! Must subset elements with a valid subscript vector.
#> ✖ Can't convert from <double> to <integer> due to loss of precision.

vec_as_subscript2(1.5)
#> Error:
#> ! Must extract element with a single valid subscript.
#> ✖ Subscript has the wrong type `double`.
#> ℹ It must be logical, numeric, or character.

It looks like it was supposed to use a lossy cast body here:

vctrs/R/subscript.R

Lines 104 to 106 in 544cc70

parent <- result$err$parent
if (inherits(parent, "vctrs_error_cast_lossy")) {
bullets <- new_cnd_bullets_subscript_lossy_cast(parent)

But it looks like parent is actually always NULL? It somehow isn't being set in the err object. Commenting out line 106 doesn't break any tests, so I'm assuming this just isn't tested

Metadata

Metadata

Assignees

Labels

bugan unexpected problem or unintended behaviorconditionsdplyr

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions