diff --git a/R/packer.R b/R/packer.R index 9e584eca..eb0000f2 100644 --- a/R/packer.R +++ b/R/packer.R @@ -505,23 +505,7 @@ unpack_vector <- function(x, nms, len, idx, shape, fixed, process) { res <- c(res, fixed) } if (!is.null(process)) { - extra <- process(res) - err <- intersect(names(extra), names(res)) - if (length(err) > 0) { - cli::cli_abort( - c("'process()' is trying to overwrite entries in your list", - i = paste("The 'process()' function should only create elements", - "that are not already present in 'scalar', 'array'", - "or 'fixed', as this lets us reverse the transformation", - "process"), - x = "{?Entry/Entries} already present: {squote(err)}")) - } - ## TODO: check names? - ## - ## TODO: this fails the multi-region use - but I think that we - ## might want a different interface there anyway as we'll - ## struggle to hold all the options here. - res <- c(res, extra) + res <- unpack_vector_process(res, process) } res } diff --git a/tests/testthat/test-packer-grouped.R b/tests/testthat/test-packer-grouped.R index a1ef64a6..7c445a8c 100644 --- a/tests/testthat/test-packer-grouped.R +++ b/tests/testthat/test-packer-grouped.R @@ -241,3 +241,10 @@ test_that("can used process with grouped packer", { list(a = list(x = 1, y = 2, z = 3), b = list(x = 3, y = 4, z = 7))) }) + + +test_that("can used process with grouped packer", { + expect_error( + monty_packer_grouped(c("a", "b"), c("x", "y"), process = TRUE), + "Expected a function for 'process'") +})