Fix Ion serialization for ArgF/OperationF/ExprF mutual recursion#406
Merged
Fix Ion serialization for ArgF/OperationF/ExprF mutual recursion#406
Conversation
9511495 to
f9b423e
Compare
This commit fixes issues with Ion serialization and deserialization when handling mutually recursive types (ArgF, OperationF, ExprF). Key changes: - Refactored ArgF.toIon to use sum type (ArgF α ⊕ OperationF α ⊕ ExprF α) to avoid double-wrapping issues during serialization - Updated deserialization to match the new serialization format - Added compile-time checks to ionRefEntry! to catch: * References to undeclared types * Self-references within ionScope! - Enhanced error messages in SymbolIdCache.id! to include context - Added round-trip tests for programs with expressions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
f9b423e to
1825dad
Compare
aqjune-aws
approved these changes
Feb 11, 2026
shigoel
approved these changes
Feb 11, 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.
Summary
ionRefEntry!was not checking that the referenced type was defined before synthesizing a reference, leading to malformed symbol ID caches and broken Ion serialization for mutually recursive types (ArgF/OperationF/ExprF)ionRefEntry!to prevent referencing undeclared types or self-referencing withinionScope!toIonrecursion forArgF/OperationF/ExprFinto a singleArgF.toIonfunction using a sum type (ArgF α ⊕ OperationF α ⊕ ExprF α) to avoid the mutual recursion that triggered the bugSymbolIdCache.id!with context strings for easier debuggingProgramandPython.CorePreludeBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.