Repository navigation
wast: parse core rec groups in component and instance types - #2798
Conversation
Component and instance types can declare core recursion groups, which `wasmprinter` prints as `(core rec ...)` like at the top level of a component, but the text parser only accepted them at the top level, so the printed text of these valid components didn't parse.
| fn expand_component_ty(&mut self, ty: &mut ComponentType<'a>) { | ||
| Expander::default().expand_decls(&mut ty.decls, |e, decl| match decl { | ||
| ComponentTypeDecl::CoreType(t) => e.expand_core_type(t), | ||
| ComponentTypeDecl::CoreRec(_) => {} |
There was a problem hiding this comment.
I think this, and the one below, need to call expand_core_type on the rec group members, right?
There was a problem hiding this comment.
I don't think these need it. Rec group members are core::Types rather than CoreTypes, so they can't be module types. For non-module types, expand_core_type only fills in a generated id that nothing uses. The top-level ComponentField::CoreRec(_) => None skips them the same way. I've added a test where a module type uses alias outer to refer to a rec group member next to an inline func type, and it roundtrips. I can add the call anyway if you'd prefer.
There was a problem hiding this comment.
Ah right, yes, I think I was misremembering what might have used to happen with core wasm modules.
Covers a module type in an instance type that refers to a type in a rec group through an outer alias, next to an inline function type.
Component and instance types can declare core recursion groups, which
wasmprinterprints as(core rec ...), like at the top level of a component. The text parser only accepted them at the top level, so this valid component printed as text that didn't parse:This parses, resolves and encodes them in component and instance types as at the top level.
Found by fuzzing with components generated from the component model's binary grammar (#2796, which skips these until this lands).