Adopted from #72: Currently globalsOf() reports on ... even when it "already knows" it's not one, e.g.
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
## ..$ <- :<environment: base>
## ..$ ~ :<environment: base>
## ..$ list:<environment: base>
## ..$ ... : 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.
str(globals)
## List of 3
## $ <- :.Primitive("<-")
## $ ~ :.Primitive("~")
## $ list:function (...)
## - attr(*, "class")= chr [1:2] "Globals" "list"
## - attr(*, "where")=List of 3
## ..$ <- :<environment: base>
## ..$ ~ :<environment: base>
## ..$ list:<environment: base>
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()?
Adopted from #72: Currently
globalsOf()reports on...even when it "already knows" it's not one, e.g.Note that
structure(NA, class = "DotDotDotList")global object with awhereattribute beingNULL. 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.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()?