False negative if method calls a different generic also using `check_dots_used`
Closed this issue · 1 comments
jimhester commented
I would expect the call to bar()
to issue a warning here, because the bar
generic is passed an argument a
without it being used by the method. Also note you get a warning if from the foo
check_dots_used()
if you do not explicitly force the promise for a
.
library(ellipsis)
foo <- function(x, ...) {
ellipsis::check_dots_used()
UseMethod("foo")
}
bar <- function(x, ...) {
ellipsis::check_dots_used()
UseMethod("bar")
}
foo.character <- function(x, ..., a = 1) {
force(a)
bar(x, ..., a = a)
}
bar.character <- function(x, ...) {
x
}
foo("hi", a = 1)
#> [1] "hi"
Created on 2018-07-09 by the reprex package (v0.2.0).
hadley commented
This seems to be fixed now:
library(ellipsis)
foo <- function(x, ...) {
ellipsis::check_dots_used()
UseMethod("foo")
}
bar <- function(x, ...) {
ellipsis::check_dots_used()
UseMethod("bar")
}
foo.character <- function(x, ..., a = 1) {
force(a)
bar(x, ..., a = a)
}
bar.character <- function(x, ...) {
x
}
foo("hi", a = 1)
#> Warning: Some components of ... were not used: a
#> [1] "hi"
Created on 2019-02-18 by the reprex package (v0.2.1.9000)