vctrs icon indicating copy to clipboard operation
vctrs copied to clipboard

Generalise base type fallback

Open lionel- opened this issue 4 years ago • 1 comments

Automatically fall back to base type if it's explicitly inherited from. This generalises the data frame fallback.

Would help with cases like tidyverse/dplyr#5296.

lionel- avatar Jun 04 '20 02:06 lionel-

Probably these ones are also connected:

> # doesn't bind on common_class_fallback 
> bind_rows(
+   tibble(a = jsonlite:::as.scalar("chr"), b = 2), 
+   tibble(b = 3, c = TRUE, d = FALSE)
+ )
Error: Can't combine `..1` <scalar> and `..2` <vctrs:::common_class_fallback>.
Run `rlang::last_error()` to see where the error occurred.
> bind_rows(
+   tibble(a = "chr", b = 2), 
+   tibble(b = 3, c = TRUE, d = jsonlite:::as.scalar(2))
+ )
Error: Can't combine `..1` <vctrs:::common_class_fallback> and `..2` <scalar>.
Run `rlang::last_error()` to see where the error occurred.
> list(
+   tibble(b = 3, c = TRUE, d = jsonlite:::as.scalar("myCharacter")),
+   tibble(a = "chr", b = 2, d = jsonlite:::as.scalar(NA))
+ ) %>% 
+   bind_rows()
Error: Can't combine `..1$d` <scalar> and `..2$d` <scalar>.
x Some attributes are incompatible.
ℹ The author of the class should implement vctrs methods.
ℹ See <https://vctrs.r-lib.org/reference/faq-error-incompatible-attributes.html>.
Run `rlang::last_error()` to see where the error occurred.

deann88 avatar Jun 12 '20 20:06 deann88