Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global being masked by local function argument with the same name #53

Closed
HenrikBengtsson opened this issue Jun 11, 2020 · 3 comments
Closed
Labels
Milestone

Comments

@HenrikBengtsson
Copy link
Collaborator

HenrikBengtsson commented Jun 11, 2020

From futureverse/doFuture#46:

findGlobals() properly identifies b as a global in:

> globals::findGlobals({ f <- function(a=0) { a }; f(b) }, substitute = TRUE)
[1] "{"     "<-"    "b"

but it fails to identify a as a global in:

> globals::findGlobals({ f <- function(a=0) { a }; f(a) }, substitute = TRUE)
[1] "{"  "<-"
@HenrikBengtsson
Copy link
Collaborator Author

The use of argument a inside that local function is critical. If we drop it, a is properly identified as a global;

> globals::findGlobals({ f <- function(a=0) { a }; f(a) }, substitute = TRUE)
[1] "{"  "<-"

and

> globals::findGlobals({ f <- function(a=0) { }; f(a) }, substitute = TRUE)
[1] "{"  "<-" "a"

Also, the call to f() is irrelevant, so we can simplify further as:

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

and

> globals::findGlobals({ function(a) NULL; a }, substitute = TRUE)
[1] "{" "a"

@HenrikBengtsson
Copy link
Collaborator Author

HenrikBengtsson commented Sep 10, 2020

Related to #61 It's not

@HenrikBengtsson
Copy link
Collaborator Author

Fixed in develop branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant