Skip to content

... can be inserted in a function signature to force users to fully name the details arguments. In this case, supplying data in ... is almost always a programming error. This function checks that ... is empty and fails otherwise.

Usage

check_dots_empty(
  env = caller_env(),
  error = NULL,
  call = caller_env(),
  action = abort
)

Arguments

env

Environment in which to look for ....

error

An optional error handler passed to try_fetch(). Use this e.g. to demote an error into a warning.

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

[Deprecated]

Details

In packages, document ... with this standard tag:

 @inheritParams rlang::args_dots_empty

Examples

f <- function(x, ..., foofy = 8) {
  check_dots_empty()
  x + foofy
}

# This fails because `foofy` can't be matched positionally
try(f(1, 4))
#> Error in f(1, 4) : `...` must be empty.
#>  Problematic argument:
#>  ..1 = 4
#>  Did you forget to name an argument?

# This fails because `foofy` can't be matched partially by name
try(f(1, foof = 4))
#> Error in f(1, foof = 4) : `...` must be empty.
#>  Problematic argument:
#>  foof = 4

# Thanks to `...`, it must be matched exactly
f(1, foofy = 4)
#> [1] 5