Skip to content

Match vctrs coercion rules for simple types #904

@hadley

Description

@hadley
library(purrr)

# Should succeed
map_lgl(0, identity)
#> Error: Can't coerce element 1 from a double to a logical
map_lgl(1, identity)
#> Error: Can't coerce element 1 from a double to a logical

map_int(1, identity)
#> Error: Can't coerce element 1 from a double to a integer

# Should error
map_chr(TRUE, identity)
#> [1] "TRUE"
map_chr(1L, identity)
#> [1] "1"
map_chr(1, identity)
#> [1] "1.000000"

Created on 2022-08-29 by the reprex package (v2.0.1)

Requires a set of (relatively straightforward) changes to set_vector_value()

May need to deprecate if this breaks too many revdeps

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions