Conversation
shikokuchuo
left a comment
There was a problem hiding this comment.
I'd probably leave this out for now and fix at vctrs, perhaps by adding an early return here: https://github.com/r-lib/vctrs/blob/ca33f4d5c9afb6e44b5373c8f2b196602b6a67aa/src/names.c#L849
Of course, defer to Davis.
DavisVaughan
left a comment
There was a problem hiding this comment.
I think we should make this change in purrr for now
I am not 100% convinced that vctrs should change at all, because we are currently consistent with names<-, which I do like.
It also kind of makes sense?
- Clearing names on
NULLshould be a no-op - But making a "named
NULL" withcharacter()is probably a user issue most of the time?
`names<-`(NULL, NULL)
#> NULL
vec_set_names(NULL, NULL)
#> NULL
`names<-`(NULL, character())
#> Error: attempt to set an attribute on NULL
vec_set_names(NULL, character())
#> Error in names(x) <- names: attempt to set an attribute on NULL
`names<-`(NULL, "x")
#> Error: attempt to set an attribute on NULL
vec_set_names(NULL, "x")
#> Error in `vec_set_names()`:
#> ! The size of `names`, 1, must be the same as the size of `x`, 0.Really the main weirdness in this particular case is that list_unchop() returns NULL at all. Technically it should return unspecified(0), which you could set empty names on to make named unspecified(0), but we try not to expose that type much. Regardless, I'm not sure I want to tweak vec_set_names() because of this corner case in list_unchop().
Fixes #1206