Skip to content

Commit 62b3fdc

Browse files
authored
Fix internal assertions renaming types using with (bytecodealliance#2215)
* Fix internal assertions renaming types using `with` This commit fixes a fuzz bug that cropped up trying to rename a type using `with`. The destination type that was created didn't have its new name registered. * Fix build on latest nightly Some new warnings cropping up to handle.
1 parent c76a5c9 commit 62b3fdc

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

crates/wit-parser/src/resolve.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3592,11 +3592,13 @@ impl Remap {
35923592
// reflect the change not only in the world key but additionally
35933593
// in the function itself.
35943594
let mut new_item = item.1.clone();
3595-
if let WorldItem::Function(f) = &mut new_item {
3596-
f.name = n.clone();
3597-
}
35983595
let key = WorldKey::Name(n.clone());
35993596
cloner.world_item(&key, &mut new_item);
3597+
match &mut new_item {
3598+
WorldItem::Function(f) => f.name = n.clone(),
3599+
WorldItem::Type(id) => cloner.resolve.types[*id].name = Some(n.clone()),
3600+
WorldItem::Interface { .. } => {}
3601+
}
36003602

36013603
let prev = get_items(cloner.resolve).insert(key, new_item);
36023604
if prev.is_some() {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: component wit % -t | validate
2+
3+
package a:b;
4+
5+
world a {
6+
resource foo;
7+
}
8+
9+
world b {
10+
include a with { foo as bar }
11+
}

0 commit comments

Comments
 (0)