Ignore when components export type definitions (#5051)
* allow a ComponentTypeRef::Type to point to a component TypeDef * component matching: don't assert exported Interface type definitions are "defined" types may be exported by their name for consumption by some component runtimes, but in wasmtime this doesn't matter (we lift and lower to types, not define them) so we should ignore these. * component-model instance tests: show that an import can export a type definition this is meaningless, but it should be accepted. (previously rejected)
This commit is contained in:
@@ -469,6 +469,7 @@ impl ComponentTypesBuilder {
|
|||||||
self.core_outer_type(0, TypeIndex::from_u32(*ty))
|
self.core_outer_type(0, TypeIndex::from_u32(*ty))
|
||||||
}
|
}
|
||||||
wasmparser::ComponentTypeRef::Func(ty)
|
wasmparser::ComponentTypeRef::Func(ty)
|
||||||
|
| wasmparser::ComponentTypeRef::Type(_, ty)
|
||||||
| wasmparser::ComponentTypeRef::Instance(ty)
|
| wasmparser::ComponentTypeRef::Instance(ty)
|
||||||
| wasmparser::ComponentTypeRef::Component(ty) => {
|
| wasmparser::ComponentTypeRef::Component(ty) => {
|
||||||
self.component_outer_type(0, ComponentTypeIndex::from_u32(*ty))
|
self.component_outer_type(0, ComponentTypeIndex::from_u32(*ty))
|
||||||
@@ -476,9 +477,6 @@ impl ComponentTypesBuilder {
|
|||||||
wasmparser::ComponentTypeRef::Value(..) => {
|
wasmparser::ComponentTypeRef::Value(..) => {
|
||||||
unimplemented!("references to value types");
|
unimplemented!("references to value types");
|
||||||
}
|
}
|
||||||
wasmparser::ComponentTypeRef::Type(..) => {
|
|
||||||
unimplemented!("references to types");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,12 @@ impl TypeChecker<'_> {
|
|||||||
// the actual type. It's ok, though, to have extra exports in the actual
|
// the actual type. It's ok, though, to have extra exports in the actual
|
||||||
// type.
|
// type.
|
||||||
for (name, expected) in expected.exports.iter() {
|
for (name, expected) in expected.exports.iter() {
|
||||||
|
// Interface types may be exported from a component in order to give them a name, but
|
||||||
|
// they don't have a definition in the sense that this search is interested in, so
|
||||||
|
// ignore them.
|
||||||
|
if let TypeDef::Interface(_) = expected {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let actual = self
|
let actual = self
|
||||||
.strings
|
.strings
|
||||||
.lookup(name)
|
.lookup(name)
|
||||||
|
|||||||
@@ -179,6 +179,12 @@
|
|||||||
))
|
))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(component
|
||||||
|
(import "host" (instance $i
|
||||||
|
(type $rec (record (field "x" (record)) (field "y" string)))
|
||||||
|
(export "some-record" (type (eq $rec)))))
|
||||||
|
)
|
||||||
|
|
||||||
(component
|
(component
|
||||||
(import "host" (instance $i
|
(import "host" (instance $i
|
||||||
(export "nested" (instance
|
(export "nested" (instance
|
||||||
|
|||||||
Reference in New Issue
Block a user