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
Is this the correct behavior? I'm generating a module in Rust but it does so incorrectly as I have a recursive type get added with multiple entries, and so .len() on the TypeSection is desynchronized. The type indices I use after the fact are then invalid and pointing to the wrong thing. pseudo-code-ish example of what I mean:
The text was updated successfully, but these errors were encountered:
birbe
changed the title
wasm_encoder does not increase type length according to amount of types specified in recursive type
wasm_encoder does not increase TypeSection num_added length proportionally to amount of types in recursive type
Jan 29, 2024
This is expected. If the type section's encoding says 5, then there can be five different rec groups that each have, say, ten items within them. In some sense a whole rec group is a single type, it just happens to introduce multiple entries into the types index space. This is actually pretty similar to how types canonicalization works. Anyways, wasm-encodermust keep track of the encoding index in order to encode properly, so if you need to keep track of the Wasm types index space (used to be 1:1 but now different) then you should implement your own counter and not rely on wasm-encoder's.
Alternatively, I think it could make sense to have a second counter that reflects the Wasm type index space, and exists just as a convenience for library users. If you want to make a PR, I could review it.
wasm-tools/crates/wasm-encoder/src/core/types.rs
Line 615 in 04ca1c5
Is this the correct behavior? I'm generating a module in Rust but it does so incorrectly as I have a recursive type get added with multiple entries, and so .len() on the TypeSection is desynchronized. The type indices I use after the fact are then invalid and pointing to the wrong thing. pseudo-code-ish example of what I mean:
The text was updated successfully, but these errors were encountered: