r-lib / sloop

S language OOP ⛵️

Home Page:https://sloop.r-lib.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error thrown when no methods exist

alexey0308 opened this issue · comments

If there are no existing methods, s4_methods_class, as a wrapper of utils::methods,
is not expected to throw an error:

setClass("virtualA", contains = "VIRTUAL")
s4_methods_class("virtualA")
#> Error in `$<-.data.frame`(`*tmp*`, class, value = "virtualA") : 
# replacement has 1 row, data has 0

However,

attr(utils::methods(class = "virtualA"), "info")
#> [1] visible from    generic isS4   
# <0 rows> (or 0-length row.names)

Maybe sloop:::methods_class can do a check for row number or other way to avoid the error...