Only check for incomplete element orderings on top-level-bindings#6035
Merged
Only check for incomplete element orderings on top-level-bindings#6035
Conversation
ChrisPenner
commented
Dec 4, 2025
Comment on lines
123
to
126
| Constructors cs -> | ||
| -- Should constructors be considered top-level? | ||
| let (hashes, _) = hashCycle cs | ||
| in tag 2 : map hashed hashes |
Member
Author
There was a problem hiding this comment.
@aryairani Do I need to consider constructors as top-level? I think so, since constructor re-orderings would be problematic when there are external references in.
Contributor
There was a problem hiding this comment.
I don't think constructors can be part of cycles so I don't think it matters? Or am I forgetting something?
Contributor
There was a problem hiding this comment.
I'm gonna merge it for now, but we can discuss soon
29af5ce to
1f4b70d
Compare
aryairani
approved these changes
Dec 5, 2025
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.
Overview
in #6007 I introduced checks to prevent creation of certain classes of problematic components for which there were multiple possible components for the same hash;
However in doing so, it also triggered failures where valid definitions contained structurally equivalent letrec-bindings
This change makes it so we only trigger the error on top-level bindings, not internal let-recs.
See https://www.notion.so/unisonweb/Cycle-Hashing-Issue-2bf5fbdd830d80c8b2ffe821c0f8638a?showMoveTo=true&saveParent=true for some more internal notes on the issue.
Implementation approach and notes
The original plan was to use
IsTopfrom the ABT Term Functor to determine whether we were hashing the top-level cycle, however this didn't work in all cases because the V2 Term Functor doesn't have an IsTop, and adding one would affect the serialization format which is no good;Instead I added an argument to
doHashCycleforisTop, and set it to true on the initial call tohashComponentsand False when we recurse.I'm not 100% positive of the behaviour here, but it does seem to be working as expected in tests.
Test coverage