Last active
August 29, 2015 14:05
-
-
Save DarwinAwardWinner/f8c64c74527c2d7d94d3 to your computer and use it in GitHub Desktop.
Wrong variable scope when callGeneric with dots argument is called by a generic that is called from another function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setGeneric("f1", signature=c("a"), | |
function(..., a) standardGeneric("f1")) | |
setMethod("f1", c(a="ANY"), function(..., a) list(a=a, ...)) | |
setMethod("f1", c(a="missing"), function(..., a) callGeneric(a=1, ...)) | |
f2 <- function(b,c,d, a) { | |
if (missing(a)) | |
f1(b=b, c=c, d=d) | |
else | |
f1(a=a, b=b, c=c, d=d) | |
} | |
## Neither of these calls triggers the callGeneric | |
f1(2,3,4, a=1) | |
f2(2,3,4, a=1) | |
## This triggers the callGeneric, but doesn't trigger the bug because we are calling f1 directly | |
f1(2,3,4) | |
## This triggers the callGeneric with f2 calling f1, so it triggers the bug | |
f2(2,3,4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment