fix ListOf compile by not relying on get__() in attribute accessors#1484
Open
kevinushey wants to merge 3 commits into
Open
fix ListOf compile by not relying on get__() in attribute accessors#1484kevinushey wants to merge 3 commits into
kevinushey wants to merge 3 commits into
Conversation
AttributeProxyPolicy is a base class whose CLASS template parameter need not provide get__() (that comes from the storage policy). ListOf inherits AttributeProxyPolicy without a storage policy, so hasAttribute() and attributeNames() failed to compile for it. Use the operator SEXP() conversion every such class provides instead, matching the existing R_getAttribNames() call. Fixes #1483.
eddelbuettel
approved these changes
Jun 26, 2026
eddelbuettel
left a comment
Member
There was a problem hiding this comment.
Nice!
Usual micro nit: ChangeLog entry in two lines, if we can?
2 tasks
Member
|
In #1464 I already removed a couple of them to rely on SEXP for ListOf, so it only makes sense to do the same here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1483.
Problem
AttributeProxyPolicy<CLASS>is a policy base class. ItsattributeNames()andhasAttribute()members fetched the underlyingSEXPviastatic_cast<const CLASS&>(*this).get__(). Butget__()is not part of this policy -- it is provided by the storage policy (PreserveStorage/NoProtectStorage).Vector,XPtrand the macro-generated classes inherit a storage policy, so they haveget__();ListOf<T>inheritsAttributeProxyPolicywithout a storage policy and has onlyget()/operator SEXP().As a result, e.g.
RestRserve'sx.hasAttribute("names")on aListOf<...>failed to compile under R >= 4.6.0:Fix
Drop
.get__()and rely on the implicitoperator SEXP()conversion that all of these classes provide. This matches the adjacentR_getAttribNames(static_cast<const CLASS&>(*this))call (which already worked forListOf) and is equivalent to the pre-4.6.0.attr()path. Both the R >= 4.6.0hasAttribute()and the pre-4.6.0attributeNames()spot are fixed (the latter had the same latent bug forListOf).Tests
Added
listof_has_attr/listof_attribute_namesexports and corresponding cases intest_listof.R. Fulltest_listof.Rpasses (20 results).