Skip to content

False positive "failed to locate global object" when using NSE #65

@DavisVaughan

Description

@DavisVaughan

In the below example, I would not have expected any failures

library(globals)

fn <- function(expr) {
  expr <- substitute(expr)
  eval(expr, envir = mtcars)
}

fn(cyl)
#>  [1] 6 6 4 6 8 6 8 4 4 6 6 8 8 8 8 8 8 4 4 4 4 8 8 8 8 4 4 4 8 6 8 4

expr <- quote(fn(cyl))

globalsOf(expr)
#> Error in globalsByName(names, envir = envir, mustExist = mustExist): Identified global objects via static code inspection (fn(cyl)). Failed to locate global object in the relevant environments: 'cyl'

This is tough because you probably search for cyl in the function environment or the global environment, but it is actually evaluated in the context of mtcars through the eval()

This came up on SO as a furrr issue related to dplyr and rlang
https://stackoverflow.com/questions/64006043/using-tidy-evaluations-with-furrr

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions