Sometimes you just want to use ... to force your users to fully name the details arguments. This function warns if ... is not empty.

check_dots_empty(env = parent.frame(), action = abort)

Arguments

env

Environment in which to look for ....

action

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

Examples

f <- function(x, ..., foofy = 8) { check_dots_empty() x + foofy } try(f(1, foof = 4))
#> Error : `...` is not empty. #> #> We detected these problematic arguments: #> * `foof` #> #> These dots only exist to allow future extensions and should be empty. #> Did you misspecify an argument? #> Backtrace: #> █ #> 1. ├─base::tryCatch(...) #> 2. │ └─base:::tryCatchList(expr, classes, parentenv, handlers) #> 3. │ ├─base:::tryCatchOne(...) #> 4. │ │ └─base:::doTryCatch(return(expr), name, parentenv, handler) #> 5. │ └─base:::tryCatchList(expr, names[-nh], parentenv, handlers[-nh]) #> 6. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 7. │ └─base:::doTryCatch(return(expr), name, parentenv, handler) #> 8. ├─base::withCallingHandlers(...) #> 9. ├─base::saveRDS(...) #> 10. ├─base::do.call(...) #> 11. ├─(function (what, args, quote = FALSE, envir = parent.frame()) ... #> 12. └─(function (..., crayon_enabled, crayon_colors, pkgdown_internet) ... #> 13. └─pkgdown::build_site(...) #> 14. └─pkgdown:::build_site_local(...) #> 15. └─pkgdown::build_reference(...) #> 16. └─purrr::map(...) #> 17. └─pkgdown:::.f(.x[[i]], ...) #> 18. └─pkgdown:::data_reference_topic(...) #> 19. └─pkgdown:::run_examples(...) #> 20. └─pkgdown:::highlight_examples(code, topic, env = env) #> 21. └─evaluate::evaluate(x, child_env(env), new_device = TRUE) #> 22. └─evaluate:::evaluate_call(...) #> 23. ├─evaluate:::timing_fn(...) #> 24. ├─evaluate:::handle(...) #> 25. │ └─base::try(f, silent = TRUE) #> 26. │ └─base::tryCatch(...) #> 27. │ └─base:::tryCatchList(expr, classes, parentenv, handlers) #> 28. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 29. │ └─base:::doTryCatch(return(expr), name, parentenv, handler) #> 30. ├─base::withCallingHandlers(...) #> 31. ├─base::withVisible(eval(expr, envir, enclos)) #> 32. └─base::eval(expr, envir, enclos) #> 33. └─base::eval(expr, envir, enclos) #> 34. ├─base::try(f(1, foof = 4)) #> 35. │ └─base::tryCatch(...) #> 36. │ └─base:::tryCatchList(expr, classes, parentenv, handlers) #> 37. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 38. │ └─base:::doTryCatch(return(expr), name, parentenv, handler) #> 39. └─f(1, foof = 4) #> 40. └─ellipsis::check_dots_empty() #> 41. └─ellipsis:::action_dots(...)
f(1, foofy = 4)
#> [1] 5