Improve handling of types and aliases in components (#5591)

This commit fixes more cases from #5565 where `export` items introducing
indices wasn't handled by accident. Additionally this fixes support for
aliasing types from instances which largely wasn't working before. Most
of the fixes here are about correctly maintaining Wasmtime's view of the
type index spaces.
This commit is contained in:
Alex Crichton
2023-01-18 18:39:21 -06:00
committed by GitHub
parent 5fd9cb405b
commit 0e92fba7e1
4 changed files with 135 additions and 7 deletions

View File

@@ -246,3 +246,77 @@
(type $t101 (list $t100))
)
"type nesting is too deep")
(component
(type (instance
(export $x "x" (instance
(type $t u32)
(export "y" (type (eq $t)))
))
(alias export $x "y" (type $t))
(export "my-y" (type (eq $t)))
))
(type (component
(import "x" (instance $x
(type $t u32)
(export "y" (type (eq $t)))
))
(alias export $x "y" (type $t))
(export "my-y" (type (eq $t)))
))
)
(component
(type $t u32)
(export $t2 "t" (type $t))
(type $r (record (field "x" $t2)))
(export "r" (type $r))
)
(component
(component
(import "x" (instance $i
(type $i u32)
(export "i" (type (eq $i)))
))
(alias export $i "i" (type $i))
(export "i" (type $i))
)
)
(component
(type $u u32)
(instance $i
(export "i" (type $u))
)
(alias export $i "i" (type $i))
(export "i" (type $i))
)
(component
(component $c
(type $t u32)
(export "t" (type $t))
)
(instance $c (instantiate $c))
(export "i" (type $c "t"))
)
(component
(component $c
(import "x" (component $c
(type $t u32)
(export "t" (type (eq $t)))
))
(instance $c (instantiate $c))
(export "i" (type $c "t"))
)
(component $x
(type $t u32)
(export "t" (type $t))
)
(instance $c (instantiate $c (with "x" (component $x))))
)