Skip to content
Prev 53820 / 63421 Next

[Bug Fix] Default values not applied to ... arguments

Yes, I see what you mean. My patch only disables JIT compilation for 
closures. If a user manually compiles a closure, however, the bug pops 
up again.

I think the bug may either lie in how the byte-compiler compiles 
closures, or how closures with compiled body's are executed by the AST 
interpreter (without my patch applied):

compiler::enableJIT(0) # turn off JIT compilation
f <- function(...) { g(...) }
g <- function(a=4, b=5, c=6) {
   print(c(missing(a), missing(b), missing(c)))
   b
}

f(1,,3) # works fine
# [1] FALSE TRUE FALSE
# [1] 5

f(1,,3) # works fine
# [1] FALSE TRUE FALSE
# [1] 5

ff_1 <- compiler::compile(f) # compile f
ff_2 <- compiler::cmpfun(f) # compile body of closure

eval(ff_1)(1,,3) # works fine
# [1] FALSE TRUE FALSE
# [1] 5

eval(ff_2)(1,,3) # bug shows up again
# [1] FALSE TRUE FALSE
# Error in g(...) : argument is missing, with no default

Thanks,
Sahil
On 07/06/2017 09:29 AM, Tomas Kalibera wrote: