Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid calling custom methods when ref()ing recursively

Merged
merged 5 commits into from Jan 26, 2019

Conversation

yutannihilation
Copy link
Contributor

@yutannihilation yutannihilation commented Jan 26, 2019

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
Contributor Author

yutannihilation commented Jan 26, 2019

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

@yutannihilation
Copy link
Contributor Author

yutannihilation commented Jan 26, 2019

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
3 checks passed
@yutannihilation yutannihilation deleted the fix-custom-class-ref branch Jan 26, 2019
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.

None yet

2 participants