fix: assignment when rhs is complex type and references lhs #3410
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.
What I did
fix #2418
How I did it
check that rhs and lhs do not overlap in parse_Assign. if they do, copy rhs to a temporary buffer, then copy to the lhs. this might not be the most efficient approach, but it is safe (and it's a relatively rare case to see in user code).
note that this doesn't touch
make_setter
directly because it would need access to the memory allocator (to allocate the temporary buffer). this would result in the fix not working in other cases where the arguments tomake_setter
overlap. i don't think there are any cases of those, but if there were, they would need to be fixed on a case by case basis.How to verify it
test cases fail on master (97ff017) but pass on this branch.
Commit message
Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)
Description for the changelog
Cute Animal Picture