You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe it is possible to add some type of metadata to subset() that give enough hints for findGlobals() to conclude that x could be part of the df object and/or the subset argument is passed without being evaluated. For instance,
argument_hint(subset, "subset", as="substitute")
such that findGlobals() will known that argument subset of subset() is passed as a "substituted" expression. This could then give findGlobals() the option to ignore whatever is passed to argument subset. With even more information, we might also be able to guide findGlobals() to - at least at run time - validate that x is available from either first argument (df) or the calling environment, e.g.
This works for futures since future (>= 1.0.0) because it now takes an optimistic approach to globals, i.e. it accepts false-positive globals (including non-existing ones as here).
Closing this since the globals package mostly exists such that the future package works.
Problem
findGlobals()
incorrectly detectsx
as a global insubset(df, x < 3)
, e.g.This is a problem with
codetools::findGlobals()
thatglobals
uses internally.Workaround
The workaround is to not use
subset()
, e.g.or to create fake local variables, e.g.
Possible approach
Maybe it is possible to add some type of metadata to
subset()
that give enough hints forfindGlobals()
to conclude thatx
could be part of thedf
object and/or thesubset
argument is passed without being evaluated. For instance,such that
findGlobals()
will known that argumentsubset
ofsubset()
is passed as a "substituted" expression. This could then givefindGlobals()
the option to ignore whatever is passed to argumentsubset
. With even more information, we might also be able to guidefindGlobals()
to - at least at run time - validate thatx
is available from either first argument (df
) or the calling environment, e.g.Now, could this be inferred from code inspection of
subset()
itself?The text was updated successfully, but these errors were encountered: