futureverse / futureverse/globals
CLEANUP: globalsOf() should not return `...`, if `...` is not a global
- Dominant language
- R
- Stars
- 29
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
Adopted from #72: Currently `globalsOf()` reports on `...` even when it "already knows" it's not one, e.g.
```r
expr <- quote(fcn <- function() ~ list(...))
print(expr)
# fcn <- function() ~list(...)
names <- globals::findGlobals(expr)
print(names)
## [1] "<-" "~" "list" "..."
globals <- globals::globalsOf(expr)
str(globals)
## List of 4
## $ <- :.Primitive("<-")
## $ ~ :.Primitive("~")
## $ list:function (...)
## $ ... : 'DotDotDotList' logi NA
## - attr(*, "class")= chr [1:2] "Globals" "list"
## - attr(*, "where")=List of 4
## ..$ <- :
## ..$ ~ :
## ..$ list:
## ..$ ... : NULL
```
Note that `structure(NA, class = "DotDotDotList")` global object with a `where` attribute being `NULL`. This is meant to signal a _potential_ misuse. However, I think it's time to graduate **globals** from this conservative approach and instead drop that `...` element, i.e.
```r
str(globals)
## List of 3
## $ <- :.Primitive("<-")
## $ ~ :.Primitive("~")
## $ list:function (...)
## - attr(*, "class")= chr [1:2] "Globals" "list"
## - attr(*, "where")=List of 3
## ..$ <- :
## ..$ ~ :
## ..$ list:
```
Comment: To do this, we also need to adjust the current package tests that assumes `...` is returned.
BTW, can we fix this also for `globals::findGlobals()`?
Contributor guide
Research direction
Start by locating the implementations of globalsOf() and findGlobals(), then inspect the package tests that cover the `...` result. Reproduce the example in the issue and update the behavior so globalsOf() omits `...` when it is not a global. Confirm the relevant tests reflect the three-item result and determine whether findGlobals() should change as well.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100