Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip reassignment of base value in Object::calculate_value #119

Merged
merged 2 commits into from
Sep 16, 2024

Conversation

heinezen
Copy link
Member

For values that are assigned in parent members, the current value is calculated dynamically by traversing the linear history of the member and applying each change to the returned value. An example where this happens can be seen here:

First():
    member : int = 0

Second(First):
    member += 5

Third(Second):
    member += 3

When retrieving Third.member, Object::calculate_value searches for the base member that uses the assignment operator (in this case First.member) and then applies all operations in linear order (= 0, + 5, + 3) to arrive at the final value 8.

Since Object::calculate_value copies the initial return value from the base member, reapplying the assignment operation is superflous as it doesn't change the value. The reassignment can also create problems as seen in #118 because None doesn't allow reassignments. Therefore, the initial reassignment is now removed.

@heinezen heinezen added bugfix restores intended behavior c++ involves C++ code labels Sep 15, 2024
TheJJ
TheJJ previously approved these changes Sep 15, 2024
Copy link
Member

@TheJJ TheJJ left a comment

Choose a reason for hiding this comment

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

apart from the funny reformatting looking good!

nyan/nyan_tool.cpp Outdated Show resolved Hide resolved
@TheJJ TheJJ merged commit 3ab28d8 into SFTtech:master Sep 16, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix restores intended behavior c++ involves C++ code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retrieving optional member value fails if None is assigned in linear history
2 participants