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
Forbidding handles within the values of map<K, V> #751
I'd like to float the idea of adding further restrictions to the V in map<K, V> type, specifically forbidding any type that transitively includes a handle where a handle here is any of own<T>, borrow<T>, future<T>, stream<T>, error-context, etc. The original motivation for me bringing this up is bytecodealliance/wasmtime#14812, but the general problem is that map<K, V> is ABI-wise just a sequence of tuples, and there's nothing preventing overlap of the keys. Bindings generators thus need to handle the case of overlapping K values and properly destroy the provided V value. In the case of resource this might involve running destructors (own<T>), updating internal metadata in a store (borrow<T>), or possibly delivering async events (future<T> and stream<T>). These are all relatively weighty operations which are easy to forget (as Wasmtime has) and not always easy to integrate.
To address this I'd like to propose an interim workaround in the meantime of forbidding these types in the V of a map<K, V>. This would be a temporary restriction until someone has a compelling use case to support this and help fill out the implementation. This would be similar to how the K type is currently limited as well.
Makes sense, especially since we can relax the restriction later if we think it's useful and worth the effort to deal with these handle issues. PR proposing the rules with WAST tests in #756
Activity
Reject various handle types in 'map' value type
lukewagner commentedon Oct 23, 2026
Makes sense, especially since we can relax the restriction later if we think it's useful and worth the effort to deal with these handle issues. PR proposing the rules with WAST tests in #756