fix: support running a module in the parent namespace via an empty id#4394
Closed
cpsievert wants to merge 1 commit into
Closed
fix: support running a module in the parent namespace via an empty id#4394cpsievert wants to merge 1 commit into
cpsievert wants to merge 1 commit into
Conversation
d03c258 to
fe28077
Compare
callModule(server, character(0)) reaches makeScope(character(0)). #4372's new destroy-callback code branched on if (!nzchar(namespace)) to detect the root scope, but nzchar(character(0)) is logical(0), so the guard errored with "argument is of length zero". A length-0 namespace is documented NS() behavior meaning "no namespace" (root) and worked before #4372 (makeScope had no nzchar guard). Treat a length-0 namespace as root only in the destroy-key logic, leaving the namespace itself untouched so NS(character(0)) keeps returning ids unchanged (normalizing to "" would instead prefix ids with a stray separator).
fe28077 to
c0e76e9
Compare
Collaborator
Author
|
Closing in favor of #4395 |
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.
After the new
session$destroy()work (#4372), the root-scope detection (if (!nzchar(namespace))) errors with "argument is of length zero" when a module is run with an empty id, e.g.callModule(server, character(0)).That empty-id idiom is how packages such as teal run a module server in the parent namespace, and it is the documented behavior of
NS():This makes the new destroy machinery handle that case. A length-0 namespace is treated as the root scope in the destroy-callback bookkeeping only; the namespace itself is left untouched so
NS(character(0))keeps returning ids unchanged (normalizing to""would instead prepend a stray-separator).Caught by reverse-dependency checks against teal.