Make WIT merging commutative#2451
Draft
fibonacci1729 wants to merge 1 commit intobytecodealliance:mainfrom
Draft
Make WIT merging commutative#2451fibonacci1729 wants to merge 1 commit intobytecodealliance:mainfrom
fibonacci1729 wants to merge 1 commit intobytecodealliance:mainfrom
Conversation
Signed-off-by: Brian Hardock <brian.hardock@fermyon.com>
fibonacci1729
commented
Feb 25, 2026
| } | ||
|
|
||
| #[test] | ||
| fn merging_is_commutative() -> Result<()> { |
Contributor
Author
There was a problem hiding this comment.
TODO: Would this test be better put into wit-component/tests/merge?
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.
Closes #1897
This PR makes the following changes made to
mod.rsto make WIT merging commutative:MergeMap::build_interface— Previously, every type and function infrom's interface was required to exist ininto's interface (strict equality). Now, one interface can be a superset of the other. If both sides have exclusive items, it fails (genuinely incompatible). If onlyfromhas extras, they're skipped in the mapping phase and handled later during the merge.Resolve::mergeinterface processing — When a mapped interface has extra types/functions fromfrom, those extras are now added to theintointerface (types added to thetypesmap, functions added to thefunctionsmap with proper span adjustment and remapping).Adds
topologically_sort_interfacesmethod onResolvethat rebuilds the interfaces arena in topological order after a merge (newly-added interfaces may have been added after existing interfaces that now depend on them).NOTE: I made use of Copilot (Claude Opus 4.6) in implementing the topological sort bits.