Update function parsing to handle externalptr and add unlistable fallback#344
Merged
Update function parsing to handle externalptr and add unlistable fallback#344
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request addresses issue #343 where FunctionReporter would fail with an error when analyzing packages that use Rcpp, due to the presence of externalptr type expressions that cannot be converted to lists. The fix makes expression parsing more robust by:
- Extracting the "listable" check into a dedicated
.is_listable_expr()function that explicitly handles external pointers - Creating a
.try_as_list()wrapper that gracefully handlesas.list()failures with logging - Updating both
.parse_function()and.parse_R6_expression()to use these new utilities
Changes:
- Refactored listable expression checking into
.is_listable_expr()with explicit handling forexternalptrtypes - Added
.try_as_list()function with error handling and fallback behavior - Updated
.parse_function()and.parse_R6_expression()to use the new helper functions - Added comprehensive unit tests for the new behavior
- Updated NEWS.md with bugfix entry
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| R/FunctionReporter.R | Added .is_listable_expr() and .try_as_list() helper functions; refactored .parse_function() and .parse_R6_expression() to use these helpers for robust expression parsing |
| tests/testthat/test-FunctionReporter-class.R | Added tests for external pointer handling and fallback behavior when as.list() fails |
| NEWS.md | Added bugfix entry documenting the fix for externalptr runtime error |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Brilliant and so fast 🚀 . Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make
.parse_functionmore robust and fix error fromexternalptr..is_listable_exprand add check forexternalptrtypeas.list(x)into.try_as_listwith fallback and logging a warningCloses #343
TODO: