Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/wac-graph/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,6 @@ impl<'a> TypeEncoder<'a> {
}

fn own(&self, state: &mut State, res: ResourceId) -> u32 {
assert!(!state.scopes.is_empty());
let res = state.current.resources[self.0[res].name.as_str()];
let index = state.current.encodable.type_count();
state.current.encodable.ty().defined_type().own(res);
Expand Down
25 changes: 25 additions & 0 deletions crates/wac-graph/tests/graphs/import-resource-alias/encoded.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(component
(import "x" (type (;0;) (sub resource)))
(import "y" (type (;1;) (eq 0)))
(type (;2;) (own 0))
(type (;3;) (own 1))
(type (;4;) (func (param "x" 2) (result 3)))
(import "f" (func (;0;) (type 4)))
(type (;5;)
(component
(import "x" (type (;0;) (sub resource)))
(import "y" (type (;1;) (eq 0)))
(type (;2;) (own 0))
(type (;3;) (own 1))
(type (;4;) (func (param "x" 2) (result 3)))
(import "f" (func (;0;) (type 4)))
)
)
(import "unlocked-dep=<test:foo>" (component (;0;) (type 5)))
(instance (;0;) (instantiate 0
(with "x" (type 0))
(with "y" (type 1))
(with "f" (func 0))
)
)
)
14 changes: 14 additions & 0 deletions crates/wac-graph/tests/graphs/import-resource-alias/graph.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"packages": [
{
"name": "test:foo",
"path": "world.wit"
}
],
"nodes": [
{
"type": "instantiation",
"package": 0
}
]
}
7 changes: 7 additions & 0 deletions crates/wac-graph/tests/graphs/import-resource-alias/world.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package example:foo;

world w {
resource x;
type y = x;
import f: func(x: x) -> y;
}
7 changes: 2 additions & 5 deletions crates/wac-types/src/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,11 +765,8 @@ impl<'a> TypeConverter<'a> {
let alias_id = self.types.add_resource(Resource {
name: name.to_owned(),
alias: Some(ResourceAlias {
owner: match self
.find_owner(ComponentAnyTypeId::Resource(id))
.expect("should have owner")
{
(Owner::Interface(id), _) => Some(*id),
owner: match self.find_owner(ComponentAnyTypeId::Resource(id)) {
Some((Owner::Interface(id), _)) => Some(*id),
_ => None,
},
source: *resource_id,
Expand Down