I am confused if this is a valid adapter module.
(adapter module (;0;)
(module (;1;)
(import "mimp" "f" (func (;0;)))
)
(import "f" (func (;0;)))
(instance (;0;) (instantiate (;module;) 1
(import "mimp" (func 0))
))
)
I believe it is invalid as although the top level imported func happens to have an import name of f, there is still a mis-match as func 0 in (import "mimp" (func 0)) refers to a func not a func with a name.
From my understanding, the correct way to do this is to wrap the imported func in an instance like so:
(adapter module (;0;)
(module (;1;)
(import "mimp" "f" (func (;0;)))
)
(import "f" (func (;0;)))
(instance (;0;)
(export "f" (func 0))
)
(instance (;1;) (instantiate (;module;) 1
(import "mimp" (instance 0))
))
)
Is my understanding correct?
If so, I believe the confusion is caused by the fact that (import "mimp" (func 0)) is only allowed in the context of instantiate of a imported module, as imported modules have single level imports. For example, this would be valid:
(adapter module (;0;)
(import "imp" (module (;1;)
(import "mimp" (func))
))
(import "f" (func (;0;)))
(instance (;0;) (instantiate (;module;) 1
(import "mimp" (func 0))
))
)
If my understanding is correct, I think this is going to trip up a lot of people as the grammar seems to allow something nonsensical. Not sure if we can fix this asides from just more documentation and examples.