pchickey opened issue #9155:
Context:
wasmtime::component::bindgen
creates aGuestPre
struct (https://github.com/bytecodealliance/wasmtime/blob/main/crates/wit-bindgen/src/lib.rs#L578) for each exported interface.
GuestPre::new
performs theexport_index
lookups 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::Component
viaComponent::env_component
) but right now there is no straightforward way to typecheck against that -load
typechecks by way ofFunc::typed
which 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
Pre
types 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::load
which would make instantiation faster, and have one less path of possible failure.
Last updated: Nov 22 2024 at 17:03 UTC