Closed gergness closed 7 years ago
yes this is intended behaviour. The environment is not meant for introspection but for hygienic evaluation. For that purpose, literals can be evaluated in the empty environment. If model.frame()
tries to evaluate complex code in the environment of the supplied formula, this is a bug in that function. It should not make the assumption that this environment has all the functions it depends on, even if they come from the base package.
As a workaround, you can check for empty enclosures and change them to the base environment.
I think I could just use quo_name() to check whether it is 1
Why not directly check the RHS rather than serialising it to text to make the check?
Awesome, that makes sense. Thanks for the pointers!
I'm trying to update my package srvyr which has used tidyeval's NSE framework and fit it into the survey package.
I've traced a bug in my code to the behavior of
quo
on integers. Instead of returning the environment where it is called, it returns an empty environment. Is this the intended behavior?FWIW, the reason I am getting this error is because the survey package uses ~1 as an indicator that each observation is an ID. It's not a particularly widespread syntactic style within the package, and could be worked around.
I think I could just use
quo_name()
to check whether it is 1 and handle as a special case. However, srvyr's code got pretty complex because I was working around something that turned out to be a bug in lazyeval, so wanted to avoid making that mistake again.Thank you!