civisanalytics / civis-r

Civis API Client for R: https://civisanalytics.com/products/civis-platform/
Other
16 stars 12 forks source link

Global environments in CivisFuture #205

Closed patr1ckm closed 4 years ago

patr1ckm commented 4 years ago

Calls to other functions in the global environment did not work when executed in the platform environment (#194). This is because the binding environment of all functions was globalenv(). The binding environment is where the function looks for values, and it is set when the function is created.

When the expression is evaluated within the future environment on platform, the binding environment of all top level functions is still globalenv (it's just a pointer). But in the platform environment, globalenv is empty.

To solve the problem, we can simply attach the future environment.

It was hard for me to test this in the unit tests, so I added the previously failing case to the nightly integration tests.

Fixes #194.