Open TylerGrantSmith opened 4 years ago
Is this the desired output?
function ()
{
b <- c(b = 2)
b$b
}
I'm not certain how this should work, so I'm not sure yet if it's fixable. Do you have a less contrived example?
Sure...you could just have the body be c(b = 2)
. I'm not sure that it is more or less contrived though.
I'm honestly a little surprised that this doesn't "work" already; the factory builder is pretty zealous about finding instances of the parameter (it'll do so inside of quotes, for example).
Actually, on that note... this fails in a different way, which might be a clue:
factory_fun <- build_factory(
fun = function() {
a <- double()
a[["a"]] <- 2
a[["a"]]
},
a
)
factory_fun(rlang::sym("b"))
This is the function it produces:
function ()
{
b <- double()
b[[b]] <- 2
b[[b]]
}
Note that the quotes around "b" have been removed. I'm somewhat shocked that this happens, and that feels worth digging into. I think I want to ignore stuff inside "" in general, but I'm not certain yet.
This would probably take some special logic to make work:
Created on 2020-06-03 by the reprex package (v0.3.0)