Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vec_data() might should unset the S4 object bit #551

Closed
DavisVaughan opened this issue Aug 29, 2019 · 0 comments · Fixed by #908
Closed

vec_data() might should unset the S4 object bit #551

DavisVaughan opened this issue Aug 29, 2019 · 0 comments · Fixed by #908

Comments

@DavisVaughan
Copy link
Member

library(vctrs)

vec_data(lubridate::seconds())
#> [1] 1

isS4(vec_data(lubridate::seconds()))
#> [1] TRUE

str(vec_data(lubridate::seconds()))
#> Formal class 'numeric' [package ""] with 0 slots
#>  list()

str(asS3(vec_data(lubridate::seconds())))
#>  num 1

Created on 2019-08-29 by the reprex package (v0.2.1)

This causes problems if vctrs_vctr objects are to be S4. In str.vctrs_vctr with a list-like vctrs object, we go through obj_str_recursive, which calls utils::str(vec_data(x)). When x is a vctrs_vctr object, vec_data() strips it down to the underlying .Data, but the S4-ness is not removed and str.default does something completely different than if it was S3 (as seen above)

krlmlr added a commit to krlmlr/vctrs that referenced this issue Mar 11, 2020
krlmlr added a commit to krlmlr/vctrs that referenced this issue Mar 11, 2020
@krlmlr krlmlr mentioned this issue Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant