Skip to content

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

Merged
hadley merged 5 commits into
r-lib:masterfrom
yutannihilation:fix-custom-class-ref
Jan 26, 2019
Merged

hadley merged 5 commits into
r-lib:masterfrom
yutannihilation:fix-custom-class-ref

Conversation

@yutannihilation

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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

@yutannihilation

yutannihilation commented Jan 26, 2019 •

Copy link
Copy Markdown
Contributor Author

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)

@hadley
hadley merged commit 05935dc into r-lib:master Jan 26, 2019
@yutannihilation
yutannihilation deleted the fix-custom-class-ref branch January 26, 2019 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants