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 #36

Merged
merged 5 commits into from Jan 26, 2019

Conversation

@yutannihilation
Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

yutannihilation commented Jan 26, 2019

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

@yutannihilation

This comment has been minimized.

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
3 checks passed
codecov/patch 100% of diff hit (target 85.41%)
Details
codecov/project 85.45% (+0.04%) compared to 9fcf642
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@yutannihilation yutannihilation deleted the yutannihilation: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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.