Skip to content

Commit

Permalink
fix argument diff checking
Browse files Browse the repository at this point in the history
  • Loading branch information
mschubert committed Feb 22, 2019
1 parent 403f9ca commit dd101c1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/check_args.r
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ check_args = function(fun, iter, const=list()) {
# check function and arguments provided
funargs = formals(fun)
required = names(funargs)[unlist(lapply(funargs, function(f) class(f)=='name'))]
required = setdiff(required, "...")

if (length(iter) == 1 && length(required) == 1 && is.null(names(iter)))
names(iter) = required

provided = names(c(iter, const))

sdiff = unlist(setdiff(required, provided))
if (length(sdiff) > 1 && sdiff != '...')
if (length(sdiff) > 1)
stop(paste("If more than one argument, all must be named:",
paste(sdiff, collapse=" ")))

Expand Down

0 comments on commit dd101c1

Please sign in to comment.