Repository navigation
Conversation
Validation accepts a component that imports one interface twice, under two plain names, through `(implements ...)` on a shared instance type. Decoding that component panics in `register_import`.
Two imports can share one instance type. The `(type (eq ...))` alias on that type is allocated once. The first import maps the alias to the WIT type. The second import maps it to the same type. Keep that mapping. The assert still rejects a mapping to another WIT type.
Conflicting type and function exports while decoding an imported interface now fail the decode instead of asserting.
This branch has not been deployed
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.
Why
wasm-tools component witandwit_parser::decoding::decodeshould handle a valid component that imports the same interface twice under different names via(implements ...), without panicking. Validation already accepts this shape. A repeated export alias that maps to the same WIT type is kept. A conflicting type or function export fails the decode instead of panicking.Fixes #2806.
What changed
register_importkeeps an export alias that is already mapped to the same WIT type. A mapping to a different WIT type fails the decode withtype export{name}was already mapped to a different type.register_importuseensure!instead ofassert!.crates/wit-component/tests/shared_instance_type.rsdecodes the reported component and checks the printed WIT.Scope
(implements ...)imports that share one instance type with no resources, and theregister_importasserts that now return errors.implementsimports sharing an instance type #2806, stay out of scope.Tradeoffs
An error on the repeated alias would stop the panic and still refuse a component WIT can represent. Two distinct instance types of this interface already printed the same WIT. The other asserts in
register_importare conflicts, so they return errors.Blast Radius
Decoding of imported interfaces in
register_import. A shared instance type with no resources now decodes to two imports of one interface. A wasm type bound to two different WIT types, or a duplicate type or function name on that interface, fails the decode instead of panicking.Verification
wasm-tools validate --features allexited 0 andwasm-tools component witpanicked atdecoding.rs:799.component witexit 0 and print both imports.cargo test -p wit-component@0.263.0 --test shared_instance_typefailed on the test commit and passed after the alias fix.cargo test -p wit-component@0.263.0 --test interfacespassed, 42 tests.