Draft
Fix __index fallback/getter priority and cross-class member pointer registration#245
__index fallback/getter priority and cross-class member pointer registration#245Conversation
Copilot
AI
changed the title
[WIP] Fix order of checking for setters and newindex fallbacks
Fix newindex setter/fallback priority across the inheritance chain
Jun 18, 2026
Owner
|
@copilot We should do the same for the __index fallback ? |
Copilot stopped work on behalf of
kunitoki due to an error
June 18, 2026 17:11
…x fallback priority semantics
- Decouple registration class C from member-owner class B in 4 getter and 4
setter push_class_property_getter/setter overloads so that base-class member
function pointers work correctly when registering properties on a derived class
(e.g. addProperty("x", &Base::getX, &Base::setX) on Class<Derived>).
- Restore __index fallback priority inside index_metamethod for two cases that
the previous WIP commit broke:
1. Static __index: static fallback must be consulted before registered static
property getters (StaticIndexFallbackCanShadowExistingStaticProperty).
2. Instance __index with allowOverridingMethods: the instance fallback must be
consulted before class-table Lua methods so Lua-side overrides take effect
(IndexFallbackMetaMethodFreeFunctorOnClassOverwriteProperty).
For plain instance __index (no allowOverridingMethods), the fallback is still
consulted only after all registered getters across the full hierarchy (Issue 242
fix remains intact).
All 1080 tests pass.
Copilot
AI
changed the title
Fix newindex setter/fallback priority across the inheritance chain
Fix Jun 18, 2026
__index fallback/getter priority and cross-class member pointer registration
kunitoki
reviewed
Jun 18, 2026
…etter/setter overloads with C and B params
Contributor
Author
Yes — |
kunitoki
approved these changes
Jun 18, 2026
kunitoki
approved these changes
Jun 18, 2026
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.
Extends the
__newindexsetter-priority fix (Issue 242) to__indexgetters: a registered getter anywhere in the hierarchy now takes priority over a derived-class__indexfallback. Also fixes two bugs introduced in the WIP commit.__indexgetter priority (Issue 242 parity)try_call_parent_indexis split into two passes — extensible getters first, fallbacks second — mirroring the__newindexfix:Cross-class member pointer registration
push_class_property_getter/setteroverloads usedCboth as the explicit registration class and as the deduced member-owner class. When registering a base-class member on a derived-class, deduction failed and the generic data-member overload won, producing compile errors. Fixed by splitting into independentC(registration class) andB(member-owner class) template parameters.__indexfallback priority — preserved casesThe WIP reordering moved the fallback too aggressively, breaking two legitimate semantics. Restored:
__index: static fallback must shadow registered static property getters (StaticIndexFallbackCanShadowExistingStaticProperty).allowOverridingMethods: instance fallback must precede class-table Lua methods so Lua-side overrides via__newindextake effect.For plain instance
__index(noallowOverridingMethods), fallback is still consulted only after all registered getters across the full hierarchy.