Skip to content

Commit 2a5746b

Browse files
authored
Merge pull request #86 from pulseengine/fix/resource-name-suffix-stripping
fix: strip $N suffix from resource name in resource tracking maps
2 parents e0f56c5 + 810b7f7 commit 2a5746b

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

meld-core/src/merger.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,16 +1673,22 @@ impl Merger {
16731673
});
16741674

16751675
// Track per-component resource import indices.
1676+
// Strip $N suffix (multi-memory dedup) from the resource name
1677+
// so the adapter can look up by bare name (e.g., "float" not "float$5").
16761678
let merged_func_idx = func_position - 1;
16771679
let eff_field = &dedup_key.1;
16781680
if let Some(rn) = eff_field.strip_prefix("[resource-rep]") {
1679-
merged
1680-
.resource_rep_by_component
1681-
.insert((unresolved.component_idx, rn.to_string()), merged_func_idx);
1681+
let bare_rn = rn.rsplit_once('$').map_or(rn, |(base, _)| base);
1682+
merged.resource_rep_by_component.insert(
1683+
(unresolved.component_idx, bare_rn.to_string()),
1684+
merged_func_idx,
1685+
);
16821686
} else if let Some(rn) = eff_field.strip_prefix("[resource-new]") {
1683-
merged
1684-
.resource_new_by_component
1685-
.insert((unresolved.component_idx, rn.to_string()), merged_func_idx);
1687+
let bare_rn = rn.rsplit_once('$').map_or(rn, |(base, _)| base);
1688+
merged.resource_new_by_component.insert(
1689+
(unresolved.component_idx, bare_rn.to_string()),
1690+
merged_func_idx,
1691+
);
16861692
}
16871693
}
16881694
ImportKind::Table(t) => {

meld-core/tests/wit_bindgen_runtime.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,9 @@ runtime_test!(
673673
);
674674
// 3-component chain: resource type mismatch fixed (H-11.8), but handle
675675
// table values still trap in wit-bindgen's ResourceTable slab code.
676+
// 3-component chain: adapter function body references wrong import (H-11.8).
677+
// The adapter calls resource.rep with comp 0's type instead of comp 5's type,
678+
// AND the adapter's call signature doesn't match (f64 param vs i32 expected).
676679
fuse_only_test!(test_fuse_wit_bindgen_resource_floats, "resource_floats");
677680
runtime_test!(
678681
test_runtime_wit_bindgen_resource_borrow_in_record,

0 commit comments

Comments
 (0)