[backport 2.11] lyaml: fix alias serialization #9790
Merged
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.
(This is a backport of PR #9777 to
release/2.11
, future2.11.3
release.)The #8350 was introduced by the commit b42302f ("lua-yaml: enable aliasing for objects returned by __serialize") so the patch is effectively reversed.
The idea is to call all object __serialize methods recursively before finding references. The new serialization pass stores the mapping from the original object to the serialized representation.
After this, the reference analysis pass and the encoding pass use this mapping to replace original objects with the serialized representation.
As result, the reference analysis has a complete information about objects and no references are missed.
Closes #8350
Closes #8310
Closes #8321