Automatically sets exit handler to run when function terminates, checking that all elements of ... have been evaluated. If you use on.exit() elsewhere in your function, make sure to use add = TRUE so that you don't override the handler set up by check_dots_used().

check_dots_used(env = caller_env(), call = caller_env(), action = abort)

Arguments

env

Environment in which to look for ... and to set up handler.

call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of abort() for more information.

action

The action to take when the dots have not been used. One of abort(), warn(), inform() or signal().

Examples

f <- function(...) { check_dots_used() g(...) } g <- function(x, y, ...) { x + y } f(x = 1, y = 2)
#> [1] 3
try(f(x = 1, y = 2, z = 3))
#> Error : 1 arguments in `...` were not used. #> We detected these problematic arguments: #> `z` #> Did you misspecify an argument?
try(f(x = 1, y = 2, 3, 4, 5))
#> Error : 3 arguments in `...` were not used. #> We detected these problematic arguments: #> `..3` #> `..4` #> `..5` #> Did you misspecify an argument?