jrandolf edited PR #14865.
jrandolf edited PR #14865:
Wasmtime ignored the type ascribed to an exported instance, as in
(export "a" (instance $i) (instance ...)), and used the type of the definition instead. So exports the ascription hides were still listed inComponent::component_typeand reachable throughget_export_index, andimplements/external-idon nested exports came from the definition rather than the ascription. The same thing happened with an instance passed to a nested component whose import declares a narrower type: if the nested component re-exported it, the host saw the caller's instance, extra exports and attributes included.This views the root component's exports through the types wasmparser validated, which already account for ascriptions and declared import types.
record_exportnow takes an instance's exports, and their attributes, from the instance's type instead of from its definition. The attributes that were carried around next to instance definitions aren't needed anymore, so they're removed.Some behaviour that embedders can see changes:
- Hidden exports no longer show up in
component_type()and can't be looked up.- Components whose narrower type hides an item Wasmtime can't re-export (e.g. an imported function) now compile instead of being rejected.
- Exports of in-component instances are ordered by the instance's type instead of
HashMaporder, so export indices are now deterministic.Ascriptions on module and component exports aren't applied yet, so
component_type()still shows those with their definition's type. This only affects reflection, since the host can't instantiate an exported module or component.The first commit is the fix. The second adds a test for the nested component case, which the same change fixes.
Closes #14852
Closes #14853
Last updated: Oct 31 2026 at 23:03 UTC