r-lib / lobstr

Understanding complex R objects with tools similar to str()
https://lobstr.r-lib.org/
Other
303 stars 27 forks source link

Avoid calling custom methods when ref()ing recursively #36

Closed yutannihilation closed 5 years ago

yutannihilation commented 5 years ago

Fix #30

Currently, ref_tree() is called recursively by lapply(). But, if the object has some custom methods, subsetting or coercing to a list might lead to unexpected results. This PR strips the class before diving into the recursion.

yutannihilation commented 5 years ago

Maybe I need to register S3 methods to fail tests...?

yutannihilation commented 5 years ago

Using vctrs::s3_register() only for this test case seems not worthy. I use this for environments, and package_version() for lists (I didn't notice node stack overflow is a catchable error!):

e <- new.env()
class(e) <- "data.frame"
as.list(e)
#> Error in unclass(x): cannot unclass an environment

Created on 2019-01-26 by the reprex package (v0.2.1)