diff --git a/R/list-transpose.R b/R/list-transpose.R index 8112f65a..390101cb 100644 --- a/R/list-transpose.R +++ b/R/list-transpose.R @@ -74,8 +74,12 @@ list_transpose <- function(x, if (length(x) == 0) { template <- integer() - } else { - template <- template %||% reduce(map(x, vec_index), vec_set_union) + } else if (is.null(template)) { + template <- reduce( + map(x, vec_index), + vec_set_union, + error_call = caller_env() + ) } if (!is.character(template) && !is.numeric(template)) { diff --git a/tests/testthat/_snaps/list-transpose.md b/tests/testthat/_snaps/list-transpose.md index d5aedd22..92809b55 100644 --- a/tests/testthat/_snaps/list-transpose.md +++ b/tests/testthat/_snaps/list-transpose.md @@ -69,6 +69,6 @@ Code list_transpose(list(x = list(a = 1, b = 2), y = list(3, 4))) Condition - Error in `fn()`: + Error: ! Can't combine `x` and `y` .