You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should type imports be restricted to defined types and resources #769
Overall I'm not aware of an actual use case of this. Resources make sense, and defined types make sense for bindings generation, but I'm not sure importing other kinds of types has much of a use case beyond "let's fill out the full matrix". I wanted to raise this as a very-not-urgent issue as a result in case others had thoughts on this.
FWIW, I think that second example should fail validation since imported types can't refer to type indices introduced by exports.
But yeah agreed that imported types with eq bounds currently aren't especially useful and it's mostly just in there to keep imports and exports symmetric (e.g., so that WIT interfaces can be equivalently imported and exported). I could imagine a hypothetical data-related applications where the host reflects on a given component's imports+types to know what data types the component expects and an imported eq-bound type was a way of declaring a named data type, but I'm not aware of anyone doing that any time soon.
In the second example though the type created by the export isn't actually used by the import, so I think it should be ok? The original rule in wasmparser was intended to handle resources and accidentally runs afoul of this case currently is what I'm thinking.
Overall I in theory like the idea of fill out the full matrix of support for everything in all the places, but that always comes at a cost of complexity and LLMs sure are having a field day in that respect. Basically it seems like we've got a lot of minor issues here and there about support the full matrix of things and fixing these issues likely has very little benefit in practice. The bugs are also minor enough that no one's really going to run into them, though, so the effect of fixing or disallowing is likely not really going to come up much anyway
I also agree with the general point that we shouldn't pointlessly "fill the matrix" for its own sake if it introduces non-trivial complexity/bug-risk. That being said, I think I forgot a more basic use case in my last comment: if I'm performing guest bindgen for a target world:
then if we ruled out eq-bound imports of non-defined/resource-types and roundtrip though a WAT component type, I think we'd lose the type mark = u64 in monotonic-clock and thus in guest bindings. If we want to go that direction, then maybe we just symmetrically delete eq-bound imports and exports of non-resource/defined types (and the WIT syntax for it, and thus the type mark = u64 in wasi:clocks)?
Activity
lukewagner commentedon Nov 18, 2026
FWIW, I think that second example should fail validation since imported types can't refer to type indices introduced by exports.
But yeah agreed that imported types with
eqbounds currently aren't especially useful and it's mostly just in there to keep imports and exports symmetric (e.g., so that WITinterfaces can be equivalently imported and exported). I could imagine a hypothetical data-related applications where the host reflects on a given component's imports+types to know what data types the component expects and an importedeq-bound type was a way of declaring a named data type, but I'm not aware of anyone doing that any time soon.alexcrichton commentedon Nov 19, 2026
In the second example though the type created by the
exportisn't actually used by the import, so I think it should be ok? The original rule in wasmparser was intended to handle resources and accidentally runs afoul of this case currently is what I'm thinking.Overall I in theory like the idea of fill out the full matrix of support for everything in all the places, but that always comes at a cost of complexity and LLMs sure are having a field day in that respect. Basically it seems like we've got a lot of minor issues here and there about support the full matrix of things and fixing these issues likely has very little benefit in practice. The bugs are also minor enough that no one's really going to run into them, though, so the effect of fixing or disallowing is likely not really going to come up much anyway
lukewagner commentedon Nov 19, 2026
Oops, right, agreed on the second example.
I also agree with the general point that we shouldn't pointlessly "fill the matrix" for its own sake if it introduces non-trivial complexity/bug-risk. That being said, I think I forgot a more basic use case in my last comment: if I'm performing guest bindgen for a target world:
then if we ruled out
eq-bound imports of non-defined/resource-types and roundtrip though a WATcomponenttype, I think we'd lose thetype mark = u64inmonotonic-clockand thus in guest bindings. If we want to go that direction, then maybe we just symmetrically deleteeq-bound imports and exports of non-resource/defined types (and the WIT syntax for it, and thus thetype mark = u64inwasi:clocks)?