Do not create attributes as a side effect of reading them#17
Merged
Conversation
AttributeValue::dereference_() was calling setAttribute() to stamp an UNDEFINED value onto an object whenever a nonexistent attribute was read. This caused phantom attributes to accumulate over time, inflating save files and polluting the object model. Instead, return UNDEFINED directly without mutation — hasAttribute() already walks the parent chain for inherited lookups. The setAttribute call was introduced in 4fdcb62 (2014) to make the getAttributeValue() path uniform, but returning early for the not-found case is simpler and avoids the side effect. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR removes a long-standing side effect where reading a missing object attribute would implicitly create and persist an UNDEFINED attribute entry, leading to “phantom” attributes and inflated save data.
Changes:
- Updates
AttributeValue::dereference_()to returnUNDEFINEDimmediately when the target object is missing or the attribute is not present, without mutating the object. - Eliminates the previous
setAttribute(..., UNDEFINED)stamping behavior on attribute reads.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Distinguishes locally-set attributes from inherited ones — useful for SITREP-style introspection and as a regression guard. The extended test asserts that reading an inherited attribute returns the parent's value without creating a local entry on the child. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
AttributeValue::dereference_() was calling setAttribute() to stamp an UNDEFINED value onto an object whenever a nonexistent attribute was read. This caused phantom attributes to accumulate over time, inflating save files and polluting the object model. Instead, return UNDEFINED directly without mutation — hasAttribute() already walks the parent chain for inherited lookups.
The setAttribute call was introduced in 4fdcb62 (2014) to make the getAttributeValue() path uniform, but returning early for the not-found case is simpler and avoids the side effect.