r-lib / vctrs

Generic programming with typed R vectors

Home Page:https://vctrs.r-lib.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`df_proxy()` should unconditionally clone

DavisVaughan opened this issue · comments

Otherwise we can end up modifying a freshly created C object in place that we didn't mean to, like in tidyverse/dplyr#6844

library(vctrs)

x <- package_version(c("4.0", "2.0.0.0.0.0.0.8"))
y <- package_version(c("1.0", "3.0" ,"4.0"))

# fine
vec_set_difference(x, y)
#> [1] '2.0.0.0.0.0.0.8'

x <- tibble::tibble(a = x)
y <- tibble::tibble(a = y)

# uh oh
vec_set_difference(x, y)
#> # A tibble: 1 × 1
#>   a$...1 $...2 $...3 $...4 $...5 $...6 $...7 $...8
#>    <int> <int> <int> <int> <int> <int> <int> <int>
#> 1      2     0     0     0     0     0     0     8

Created on 2023-05-08 with reprex v2.0.2.9000