Skip to content

Fix double evaluation of active bindings in env_get() on old R#1896

Merged
lionel- merged 3 commits into
mainfrom
fix-get
Apr 17, 2026
Merged

Fix double evaluation of active bindings in env_get() on old R#1896
lionel- merged 3 commits into
mainfrom
fix-get

Conversation

@lionel-
Copy link
Copy Markdown
Member

@lionel- lionel- commented Apr 16, 2026

Closes #1893

Comment thread src/rlang/env-binding.c Outdated
Comment on lines +188 to +194
// `Rf_findVarInFrame3()` evaluates active bindings via `BINDING_VALUE()`
// on R < 4.5, so skip `env_find()` to avoid evaluating them twice (#1893)
if (type != R_ENV_BINDING_TYPE_active) {
r_obj* value = env_find(env, sym);
if (r_typeof(value) == R_TYPE_dots) {
return value;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it also be better to do a pointer comparison of sym against Rf_install("...") to see if we even need to do the env_find()? Or maybe you can have a DOTSXP in an env even if the name isn't ... so that might not catch every case?

I'm just mildly annoyed from a performance perspective that you have to kind of "get" the thing twice, but i guess its also for R < 4.5 so its probably fine as is i suppose...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh good idea!

Base automatically changed from c-format to main April 16, 2026 14:01
@lionel- lionel- merged commit e58d448 into main Apr 17, 2026
11 checks passed
@lionel- lionel- deleted the fix-get branch April 17, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rlang 1.2.0: env_get() evaluates active bindings twice in R <= 4.4

2 participants