Skip to content

Fix obj_size() with immediate bindings#88

Open
lionel- wants to merge 2 commits intomainfrom
bugfix/env-iteration
Open

Fix obj_size() with immediate bindings#88
lionel- wants to merge 2 commits intomainfrom
bugfix/env-iteration

Conversation

@lionel-
Copy link
Member

@lionel- lionel- commented Feb 4, 2026

Closes #48

I fixed the issue and made progress towards conformant API by switching to an iteration approach that uses the accessors discussed in https://bugs.r-project.org/show_bug.cgi?id=18928.

The first commit imports the rlang C library.

The second commit uses the new environment API of r-lib/rlang#1871 to iterate over environments. This API implements non-compliant fallbacks for older R versions (currently that's all R versions). Once https://bugs.r-project.org/show_bug.cgi?id=18928 is merged, updating the rlang library will be enough to make lobstr compliant.

Because we can no longer inspect the environment frames/hashtables, we compute an estimation of their size instead.

Copy link
Member

@DavisVaughan DavisVaughan left a comment

Choose a reason for hiding this comment

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

Nice!


case R_ENV_BINDING_TYPE_unbound:
break;
}
Copy link
Member

Choose a reason for hiding this comment

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

To be super safe, I wonder if you should add a default: case that errors. I always get burned by this in C where it doesn't care whether you are exhaustive or not in your switches

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.

Bad binding access

2 participants