rlang
rlang copied to clipboard
Should `inject()` strip srcrefs?
To avoid this problem:
library(rlang)
power1 <- function(exp) {
inject(function(x) x ^ !!exp)
}
funs <- lapply(1:2, power1)
funs
#> [[1]]
#> function(x) x ^ !!exp
#> <environment: 0x107033e08>
#>
#> [[2]]
#> function(x) x ^ !!exp
#> <environment: 0x107032ba8>
lapply(funs, \(f) structure(f, srcref= NULL))
#> [[1]]
#> function (x)
#> x^1L
#> <environment: 0x107033e08>
#>
#> [[2]]
#> function (x)
#> x^2L
#> <environment: 0x107032ba8>
Created on 2023-11-02 with reprex v2.0.2