Skip to content

Commit 8c210ea

Browse files
committed
Fix promise evaluation in r_env_get()
1 parent c330acb commit 8c210ea

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/rlang/env.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "cnd.h"
88
#include "globals.h"
99
#include "obj.h"
10+
#include "rlang.h"
1011
#include "sym.h"
1112

1213
#define RLANG_USE_R_EXISTS (R_VERSION < R_Version(4, 2, 0))
@@ -59,15 +60,19 @@ r_obj* r_env_find_anywhere(r_obj* env, r_obj* sym) {
5960
}
6061

6162
#if R_VERSION < R_Version(4, 5, 0)
63+
// Compatibility implementation for `R_getVar()`:
64+
// - Throws if not found
65+
// - Evaluates promises
6266
static inline
6367
r_obj* r_env_get(r_obj* env, r_obj* sym) {
6468
r_obj* out = r_env_find(env, sym);
6569

6670
if (out == r_syms.unbound) {
6771
r_abort("object '%s' not found", r_sym_c_string(sym));
6872
}
73+
6974
if (r_typeof(out) == R_TYPE_promise) {
70-
Rf_eval(out, env);
75+
return Rf_eval(out, env);
7176
}
7277

7378
return out;

0 commit comments

Comments
 (0)