CLEANUP: globalsOf() should not return `...`, if `...` is not a global

Aperta
#75 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
r
Ambito
tooling

Direzione di ricerca

Inizia individuando le implementazioni di globalsOf() e findGlobals(), quindi esamina i test del package che coprono il risultato .... Riproduci l’esempio nell’issue e aggiorna il comportamento in modo che globalsOf() ometta ... quando non è una variabile globale. Verifica che i test pertinenti riflettano il risultato di tre elementi e determina se anche findGlobals() debba essere modificata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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()?

Lingua principale
R
Stelle
29
Fork
3
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di futureverse/globals

Tutte le issue di futureverse/globals

Issue simili

Altre issue su R

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.