I'm upgrading some fairly old code that still dealt with wasmparser::Type which made it fairly straightforward to figure out the arguments and return values of a function. I'd collect all Types into a list and each function section entry would reference a specific Type by index and Type::Func would contain info I needed.
With recursive types I'm no longer sure how to deal with this? Is it even possible anymore to know definitely what is the function type within a module by just parsing module itself and nothing else?
(I understand that I would not regress much if I checked that RecGroup::is_explicit_rec_group() == false, asserted that types() iterator gave me just one value and worked from there, but that's clunky and it sounds that perturbation as simple as adding (rec ...) around a function type would already make this approach fail?)
rec groups are used to define recursive types from the GC proposal, but otherwise everything remains the same. Modules are still standalone, functions still specify their type by an index, and the index that a function type points to must be a function type, and function types are still a list of params/results.
Could you clarify a bit more what you're doing and how rec groups make that more complicated?
Err, sorry I missed the response here ^^ So my primary goal and requirement is to be able to inspect the number and size of function arguments. I do that to make an estimate on the worst-case stack use for the functions and blocks. From what you're saying it seems like rec types cannot occur in any shape or form in types that are referenced by the functions section or by blocks? That simplifies a lot, though at the same time I just went with into_iter_err_on_gc_types cause I don't actually care about supporting anything gc related at this time.
Looking at plain wasm structure I was under an impression that function types become capable of referencing these other recursive types which appeared to be difficult to grok statically and in isolation.
ah yeah if you don't want to support GC then that method is what you want, and while function-references does enable more types than before they'll show up as ValType::Ref(...) which you can still approximate the size of and count as one param/result.
Last updated: Dec 06 2025 at 05:03 UTC