Closed t-kalinowski closed 1 week ago
Hmmmm, I wonder if we should add a error wrapper in method<-
since it has a bit more context. I think ideally I'd want
foo <- function() {}
method(foo, class_character) <- function(...) {}
#> Error: Failed to register <character> method for <foo> generic
#> `generic` is a function, but not an S3 generic function
But looking at the traceback, maybe we can't get the name of the generic because of the *tmp*
substitution?
I don't think it's possible to get the original expression for x
in a call like foo(x) <-
through introspection.
> `foo<-` <- function(x, value) {
+ print(sys.calls())
+ }
>
> x <- function() {}
>
> foo(x) <- "some val"
[[1]]
`foo<-`(`*tmp*`, value = "some val")
Yeah, so the best we could do is mention the method. Maybe something like this?
foo <- function() {}
method(foo, class_character) <- function(...) {}
#> Error: Failed to register <character> method for generic
#> `generic`, function(...) is a function, but not a generic
Closes #447