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

Some but not all reserved keywords are detected as globals #50

Open
3 of 9 tasks
HenrikBengtsson opened this issue Dec 8, 2019 · 0 comments
Open
3 of 9 tasks

Comments

@HenrikBengtsson
Copy link
Collaborator

HenrikBengtsson commented Dec 8, 2019

Just a note for now: The following reserved keywords are flagged as globals by findGlobals() although they're "cannot" be globals:

  • if

  • for

  • repeat

  • break

  • while

  • next

  • Ok, technically, the can.

Note that some of the reserved keywords in R are not picked up, e.g.

  • function
  • else
  • in

Reproducible examples

Keyword: function

> globals::findGlobals(function() NULL, substitute = TRUE)
[1] character(0)

Keywords: if and else

> globals::findGlobals(if (TRUE) 1 else 0, substitute = TRUE)
[1] "if"

Keywords: for and in

> globals::findGlobals(for (x in NULL) NULL, substitute = TRUE)
[1] "for"

Keywords: repeat and break

> globals::findGlobals(repeat break, substitute = TRUE)
[1] "repeat" "break"

Keywords: while and next

> globals::findGlobals(while(FALSE) next, substitute = TRUE)
[1] "while"    "next"

PS. codetools::findGlobals() does the same.

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

No branches or pull requests

1 participant