@@ -242,6 +242,40 @@ test_that("fill constructors spread inside c()", {
242242 expect_quick_identical(logical_fill , list (c(TRUE , FALSE )))
243243})
244244
245+ test_that(" local closures can shadow fill constructors in c() and array()" , {
246+ numeric_shadow <- function () {
247+ numeric <- function () c(1 , 2 )
248+ combined <- c(numeric (), 3 )
249+ reshaped <- array (numeric (), dim = c(1L , 2L ))
250+ list (combined = combined , reshaped = reshaped )
251+ }
252+ expect_quick_identical(numeric_shadow , list ())
253+
254+ integer_shadow <- function () {
255+ integer <- function () c(1L , 2L )
256+ combined <- c(integer(), 3L )
257+ reshaped <- array (integer(), dim = c(1L , 2L ))
258+ list (combined = combined , reshaped = reshaped )
259+ }
260+ expect_quick_identical(integer_shadow , list ())
261+
262+ double_shadow <- function () {
263+ double <- function () c(1 , 2 )
264+ combined <- c(double(), 3 )
265+ reshaped <- array (double(), dim = c(1L , 2L ))
266+ list (combined = combined , reshaped = reshaped )
267+ }
268+ expect_quick_identical(double_shadow , list ())
269+
270+ logical_shadow <- function () {
271+ logical <- function () c(1L , 2L )
272+ combined <- c(logical (), 3L )
273+ reshaped <- array (logical (), dim = c(1L , 2L ))
274+ list (combined = combined , reshaped = reshaped )
275+ }
276+ expect_quick_identical(logical_shadow , list ())
277+ })
278+
245279test_that(" fill constructors materialize where an array is required" , {
246280 # A fill reaching c() through an expression is a real array, not a
247281 # scalar literal with claimed dims (which emitted one element where the
0 commit comments