diff --git a/R/method-register.R b/R/method-register.R index 6f35d1cf..5996d0cc 100644 --- a/R/method-register.R +++ b/R/method-register.R @@ -181,9 +181,14 @@ check_method <- function(method, generic, name = paste0(generic@name, "(???)")) if (!"..." %in% generic_args && !identical(generic_formals, method_formals)) { msg <- sprintf( - "%s() lacks `...` so method formals must match generic formals exactly", + "%s() generic lacks `...` so method formals must match generic formals exactly.", generic@name ) + bullets <- c( + sprintf("- generic formals: %s", show_args(generic_formals, name = generic@name)), + sprintf("- method formals: %s", show_args(method_formals, name = generic@name)) + ) + msg <- paste0(c(msg, bullets), collapse = "\n") stop(msg, call. = FALSE) } diff --git a/tests/testthat/_snaps/method-register.md b/tests/testthat/_snaps/method-register.md index 9953586f..8a201d72 100644 --- a/tests/testthat/_snaps/method-register.md +++ b/tests/testthat/_snaps/method-register.md @@ -81,7 +81,9 @@ check_method(function(x, y) { }, foo) Condition Error: - ! foo() lacks `...` so method formals must match generic formals exactly + ! foo() generic lacks `...` so method formals must match generic formals exactly. + - generic formals: foo(x) + - method formals: foo(x, y) # check_method warn if default arguments don't match