Add validations for imports during instantiation (#8086)
* At instantiation time, check the types of exports against their corresponding imports, and trap if they don't match. * Exported memories and tables must be a subtype of the corresponding import. * Function types aren't checked yet because we don't have a way to check the exact type of function re-exports; i.e. [exact-func-imports.wast](https://github.com/WebAssembly/binaryen/blob/main/test/spec/exact-func-import.wast#L85) would fail to instantiate on line 85. * Copy `exact-func-import.wast` from the [testsuite](https://github.com/WebAssembly/testsuite/blob/main/proposals/custom-descriptors/exact-func-import.wast) repo, which now passes. * Fix `ref_func.wast` and `tags.wast` which also otherwise fail with the new validations. * Fix getMemoryInstanceInfo to follow import chains rather than just one import. * Also fix getMemorySize to read the runtime page size from imports when applicable. This is necessary to keep track of page sizes correctly when we import a memory that's later grown e.g. in test/spec/imports.wast. * Fixes `imports0`, `imports2`, `linking0`, `linking3` and partially fixes `imports`, `imports3` and `memory64`. As followups, we should improve the handling of the "spectest" module by implementing the [implicit definition](https://github.com/WebAssembly/spec/blob/main/interpreter/README.md#spectest-host-module) described by the spec, and we should add tracking for exact types of function re-exports so that we can enable import-time type checking for function types.
S
Steven Fontanella committed
201149ca06da7f871ffa8be7a23eb101886f10bf
Parent: 4236103
Committed by GitHub <noreply@github.com>
on 1/2/2026, 8:56:08 PM