futureverse / futureverse/globals

findGlobals() does not acknowledge when expression attaches packages via library() etc.

Open
#5 2 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
R
Stars
29
Forks
3
PR merge metrics
No merged PRs in 30d

Description

`findGlobals()` does not acknowledge when expression attaches packages via `library()` etc, e.g.

``` r
> library(globals)
> findGlobals(substitute({ globals::getGlobals }, env=list()))
[1] "::" "{"
> findGlobals(substitute({ getGlobals }, env=list()))
[1] "{" "getGlobals"
> findGlobals(substitute({ library(globals); getGlobals }, env=list()))
[1] "{" "getGlobals" "library"
```

In case someone wonders about `library()`;

``` r
> codetools::findGlobals(function() { library(globals); getGlobals })
[1] "{" "getGlobals" "library"

> globals::findGlobals({ library(globals); getGlobals }, substitute=TRUE)
[1] "{" "getGlobals" "library"

> library(globals)
> g <- getGlobals({ library(globals); getGlobals }, substitute=TRUE)
> g <- cleanup(g)
> str(g)
List of 1
$ getGlobals:function (expr, envir = parent.frame(), ..., method = c("conservative",
"liberal"), tweak = NULL, substitute = FALSE, mustExist = TRUE, unlist = TRUE)
- attr(*, "class")= chr [1:2] "Globals" "list"
> environment(g$getGlobals)

```

Contributor guide

Open the contributing guide

Research direction

Start by inspecting the implementation and tests for findGlobals(), then run the reproducing expressions shown in the issue, including library(globals) followed by getGlobals. Done means the result acknowledges the attached package so getGlobals is resolved rather than reported as a global, while preserving the existing behavior for the other examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.