fix: name collisions and empty namespaces#1331
Draft
jsturtevant wants to merge 4 commits intohyperlight-dev:mainfrom
Draft
fix: name collisions and empty namespaces#1331jsturtevant wants to merge 4 commits intohyperlight-dev:mainfrom
jsturtevant wants to merge 4 commits intohyperlight-dev:mainfrom
Conversation
When a WIT interface has no namespace path (e.g. no package prefix), the generated Rust code would produce invalid double-colon (::) paths. Add guards to emit correct paths when the namespace is empty. Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
When multiple WIT packages exports an interface with the same name (e.g. a:pkg/types and b:pkg/types), the generated Rust trait would have duplicate associated types and getters, causing compilation to hang or fail. Add collision detection that scans import declarations for duplicate interface names. When a collision is found, the full namespace path is prepended to produce unique names (e.g. APkgTypes vs BPkgTypes). Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Apply the same import_member_names() collision detection to guest.rs that was already applied to host.rs and rtypes.rs. Without this, guest_bindgen! would generate duplicate type aliases and getter functions when two packages export interfaces with the same name. Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Add collision.wasm to the witguest-wit Justfile recipe so it is built from the collision-test/ WIT directory alongside interface.wasm and twoworlds.wasm. Upload and download it as a CI artifact so the collision integration tests can run in the test workflow. Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
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.
Add collision.wasm to the witguest-wit Justfile recipe so it is built from the collision-test/ WIT directory alongside interface.wasm and twoworlds.wasm. Upload and download it as a CI artifact so the collision integration tests can run in the test workflow.
fixes: #1329
fixes: #1328
Signed-off-by: James Sturtevant jsturtevant@gmail.com