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_slice<- for POSIXlt does not clone #1951

Open
antalk2 opened this issue Aug 23, 2024 · 0 comments
Open

vec_slice<- for POSIXlt does not clone #1951

antalk2 opened this issue Aug 23, 2024 · 0 comments

Comments

@antalk2
Copy link

antalk2 commented Aug 23, 2024

For a POSIXlt vector x0

After x <- x0
vec_slice(x,1) <- another
does not only change the value of x,
it also changes the value of x0 .
Is this expected?

library(vctrs)

# `[<-` works as expected (clones x)

x0_reference <- as.POSIXlt("2020-11-01")
x0           <- as.POSIXlt("2020-11-01")
another      <- as.POSIXlt("9020-11-01")
x <- x0

x[1] <- another
identical(x0, x0_reference) # TRUE
identical(x , x0          ) # FALSE

#
# `vec_slice<-` does not clone
#

x0_reference <- as.POSIXlt("2020-11-01")
x0           <- as.POSIXlt("2020-11-01")
another      <- as.POSIXlt("9020-11-01")
x <- x0

vec_is(x) # TRUE

vec_slice(x,1) <- another # also changes x0

identical(x0, x0_reference) # FALSE
identical(x , x0          ) # TRUE
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

No branches or pull requests

1 participant