@@ -252,6 +252,40 @@ test_that("symbolic fill spreading preserves pointer-sized lengths", {
252252 expect_quick_identical(fn , list (c(2 , 4 , 6 )))
253253})
254254
255+ test_that(" local closures can shadow fill constructors in c() and array()" , {
256+ numeric_shadow <- function () {
257+ numeric <- function () c(1 , 2 )
258+ combined <- c(numeric (), 3 )
259+ reshaped <- array (numeric (), dim = c(1L , 2L ))
260+ list (combined = combined , reshaped = reshaped )
261+ }
262+ expect_quick_identical(numeric_shadow , list ())
263+
264+ integer_shadow <- function () {
265+ integer <- function () c(1L , 2L )
266+ combined <- c(integer(), 3L )
267+ reshaped <- array (integer(), dim = c(1L , 2L ))
268+ list (combined = combined , reshaped = reshaped )
269+ }
270+ expect_quick_identical(integer_shadow , list ())
271+
272+ double_shadow <- function () {
273+ double <- function () c(1 , 2 )
274+ combined <- c(double(), 3 )
275+ reshaped <- array (double(), dim = c(1L , 2L ))
276+ list (combined = combined , reshaped = reshaped )
277+ }
278+ expect_quick_identical(double_shadow , list ())
279+
280+ logical_shadow <- function () {
281+ logical <- function () c(1L , 2L )
282+ combined <- c(logical (), 3L )
283+ reshaped <- array (logical (), dim = c(1L , 2L ))
284+ list (combined = combined , reshaped = reshaped )
285+ }
286+ expect_quick_identical(logical_shadow , list ())
287+ })
288+
255289test_that(" fill constructors materialize where an array is required" , {
256290 # A fill reaching c() through an expression is a real array, not a
257291 # scalar literal with claimed dims (which emitted one element where the
0 commit comments