Repository navigation
Ship box module functions to the worker and keep NULL function bodies - #31
Open
dawiegriesel wants to merge 1 commit into
Open
dawiegriesel wants to merge 1 commit into
dawiegriesel wants to merge 1 commit into
Conversation
A box module's environment is not an R namespace, so functions defined in a module, or attached by a top-level box::use(), were neither shipped nor reported missing and failed with "could not find function" on the worker. They are now shipped as the global environment's are (#29). S4 generics, such as DBI::dbConnect() imported through box, are shipped as they are so they keep the method tables dispatch needs. With srcrefs, `function(e) NULL` lost its body when capture rewrote it, since assigning NULL into a call deletes the element; only call bodies are now rewritten (#30).
This branch has not been deployed
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.
Summary
namespace:<mod>) and the one a top-levelbox::use()attaches (mod:<path>) are not R namespaces, socollect_globals()skipped their functions without shipping them or reporting them missing, and the task failed on the worker with "could not find function". These environments are now recognised (is_box_env(), using box's own.__module__.marker or thebox$modclass) and their functions are shipped as the global environment's are, together with the helpers their module defines.DBI::dbConnect()imported withbox::use()is now shipped as it is instead of being rebound to a clone of its environment, which lost the method tables and broke dispatch.function(e) NULLassignedNULLinto the call, which deleted the body so the function returned its srcref. Only call bodies are rewritten now.Tests
New tests in
tests/testthat/test-capture.Rcover a function defined in a box module, an imported box function and its module helpers, a top-levelbox::use()attachment, an end-to-endtestServer()run on the worker, an imported S4 generic, and a NULL body parsed withkeep.source = TRUE.Fixes #29
Fixes #30