Always-annotate types in option/result/empty list literals#15
Merged
Conversation
This was referenced May 8, 2026
Merged
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
Make the value literal format truly lossless for chain replay.
The format added in #13 had a hidden lossiness: two
Valueinstances with different stored type info could produce identical Display output. For example:Value::Result { ok_type: String, err_type: String, value: Ok(Tuple([])) }displays asok<string>(())Value::Result { ok_type: Tuple([]), err_type: String, value: Ok(Tuple([])) }also displays asok<string>(())Different stored types → different CGRF bytes → different chain hashes → replay diverges.
Fix
Always annotate the type info that can't be inferred from the value:
nonenone<list<u8>>some(42u32)some<u32>(42u32)ok(42u32)ok<u32, string>(42u32)err("bad")err<u32, string>("bad")[][]<u8>Non-empty lists still infer
elem_typefrom the first item.Verification
packr-abitests pass, including newtest_cgrf_round_tripthat asserts byte-identical CGRF afterDisplay → parse → encodefor the cases that previously diverged.cargo clippy -p packr-abi -- -D warningsclean.Replay complete: 4/4 events verified via streaming).🤖 Generated with Claude Code