What is "named type restriction" and how to mitigate it? #2122
|
Hi everyone! I'm currently experimenting with the Component Model and encountered some behavior I do not understand and haven't found documentation for. Basically, I want to export a variant type from a component definition and One such failing test case from the (component
(type $t (record (field "f" u32)))
(type $f (variant (case "c" $t)))
(export "f" (type $f))
)My understanding is that How can this example be turned into one that validates? Where are these rules discussed? (I did not find anything in the Explainer, but maybe I was looking for the wrong stuff/ did not connect the dots.) Cheers, |
Replies: 1 comment 1 reply
|
This restriction may not be super well documented in the spec (I haven't checked in awhile), but basically what you need to do is: (export $t' "t" (type $t))and then use Exporting a type introduces a new type index, and that new type index is the named one which must be used. |
This restriction may not be super well documented in the spec (I haven't checked in awhile), but basically what you need to do is:
and then use
$t'in the case.Exporting a type introduces a new type index, and that new type index is the named one which must be used.