The following attempt at making a unary method for - fails:
library(S7)
foo <- new_class("foo")
method(`-`, list(foo, class_missing)) <- function(e1, e2) {"Minus foo"}
-foo()
#> Error in Ops.S7_object(foo()): argument "e2" is missing, with no default
Created on 2025-03-28 with reprex v2.1.1
I think the cause is that the following lines don't consider the possibility of missing e1 or e2.
|
cnd <- tryCatch( |
|
return(base_ops[[.Generic]](e1, e2)), |
|
S7_error_method_not_found = function(cnd) cnd |
|
) |
The following attempt at making a unary method for
-fails:Created on 2025-03-28 with reprex v2.1.1
I think the cause is that the following lines don't consider the possibility of missing
e1ore2.S7/R/method-ops.R
Lines 19 to 22 in db59642