Skip to content

Commit 2d838aa

Browse files
Fix issue in vec_restore restoring unpruned vectors
1 parent 4833e43 commit 2d838aa

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

R/vctrs.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ method(vec_restore, class_vecvec) <- function(x, to, ...) {
1616
S7_data(to) <- x$i
1717
# Invoke pruning of slots
1818
out <- to[seq_along(to)]
19-
attributes(out) <- attributes(to)
2019
return(out)
2120
}
2221

tests/testthat/test-vctrs.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ test_that("vctrs::vec_slice basic", {
5454
expect_equal(as.integer(vec_slice(vv, c(1L, 10L))), c(1L, 10L))
5555
})
5656

57+
test_that("vctrs::vec_slice with mixed types", {
58+
vv <- vecvec(1:5, letters)
59+
expect_equal(as.integer(vec_slice(vv, 1:5)), 1:5)
60+
expect_equal(as.character(vec_slice(vv, 6:10)), letters[1:5])
61+
})
62+
5763
test_that("vctrs::vec_slice out-of-order indices", {
5864
vv <- vecvec(1:5, 6:10)
5965
idx <- c(10L, 3L, 7L, 1L)

0 commit comments

Comments
 (0)