pchickey opened issue #9155:
Context:
wasmtime::component::bindgencreates aGuestPrestruct (https://github.com/bytecodealliance/wasmtime/blob/main/crates/wit-bindgen/src/lib.rs#L578) for each exported interface.
GuestPre::newperforms theexport_indexlookups to validate that each function in the interface exists. However, it does not typecheck the functions innew- instead, they are typechecked inGuestPre::load, which takes a store and therefore must occur at instantiation time.The information to typecheck these exports exists in the
Component(specifically in thewasmtime_environ::component::ComponentviaComponent::env_component) but right now there is no straightforward way to typecheck against that -loadtypechecks by way ofFunc::typedwhich requires a store argument, but ultimately ends up getting all the types out of that same env_component information.We should fix this so that GuestPre can be used to validate that the component's exports are all typechecked. This is useful for two reasons:
- it allows bindgen's
Pretypes to be used to fully validate a component is well typed without instantiating it - it already does this for imports, only exports are missing- we could potentially eliminate type checking performed in the (
Instance::get_typed_func)[https://github.com/bytecodealliance/wasmtime/blob/main/crates/wit-bindgen/src/lib.rs#L2577] performed inGuestPre::loadwhich would make instantiation faster, and have one less path of possible failure.
pchickey closed issue #9155:
Context:
wasmtime::component::bindgencreates aGuestPrestruct (https://github.com/bytecodealliance/wasmtime/blob/main/crates/wit-bindgen/src/lib.rs#L578) for each exported interface.
GuestPre::newperforms theexport_indexlookups to validate that each function in the interface exists. However, it does not typecheck the functions innew- instead, they are typechecked inGuestPre::load, which takes a store and therefore must occur at instantiation time.The information to typecheck these exports exists in the
Component(specifically in thewasmtime_environ::component::ComponentviaComponent::env_component) but right now there is no straightforward way to typecheck against that -loadtypechecks by way ofFunc::typedwhich requires a store argument, but ultimately ends up getting all the types out of that same env_component information.We should fix this so that GuestPre can be used to validate that the component's exports are all typechecked. This is useful for two reasons:
- it allows bindgen's
Pretypes to be used to fully validate a component is well typed without instantiating it - it already does this for imports, only exports are missing- we could potentially eliminate type checking performed in the (
Instance::get_typed_func)[https://github.com/bytecodealliance/wasmtime/blob/main/crates/wit-bindgen/src/lib.rs#L2577] performed inGuestPre::loadwhich would make instantiation faster, and have one less path of possible failure.
Last updated: Dec 13 2025 at 21:03 UTC