Closed olliptln closed 9 months ago
This is a bug, which seems to stem from the fact that wit_parser
treats imported types differently than types in the same interface. It is fixed in 30c202620c0b35cdfcaef829ea4e7b70ba4516dc and version 0.1.15
. You're the first one to be seriously using resources, so I guess you're running into all the issues haha. Feel free to let me know if you encounter any more problems!
Trying to use a resource as a type doesn't appear to work. I'm not sure if this is a bug, missing feature, or if I'm just trying to misuse the package.
Adapted from the resource example, I bring the resource type to use and add the resource as a result type to the function:
Trying to instantiate the linker, where the appropriate resources and functions are already defined, gives the following error:
Cannot instantiate resource as type
which comes from:
The problem is specifically the "use bar.{myresource}" line.
Doing this should be supported in wit, according to
https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md
, for example the last example on that page.From types.rs it seems Own and Borrow resources are supported, but not resources as such. Maybe the wit parser should interpret this as a Own resource, as that's the default?