From c7583d42b7b0035ec4510023b3bcdba9cc87615b Mon Sep 17 00:00:00 2001 From: Ralf Anton Beier Date: Mon, 16 Mar 2026 07:00:55 +0100 Subject: [PATCH 1/2] fix: propagate resource type aliases in build_resource_type_to_import Component function parameters may reference a resource via an ExportAlias (e.g., Borrow(24) where type 24 is ExportAlias(25)), while canonical ResourceRep/ResourceNew entries use the target type. The resource map now includes both alias source and target IDs so resolve_resource_positions can find imports for either type ID. This partially fixes resource detection in 3-component chains where the intermediate component's type system has aliased resource types. Co-Authored-By: Claude Opus 4.6 (1M context) --- meld-core/src/resolver.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/meld-core/src/resolver.rs b/meld-core/src/resolver.rs index 691c827..e5641cd 100644 --- a/meld-core/src/resolver.rs +++ b/meld-core/src/resolver.rs @@ -820,6 +820,40 @@ fn build_resource_type_to_import( } } + // Step 6: Propagate entries through resource type aliases. + // + // Function parameter types may reference a resource via an ExportAlias + // (e.g., Borrow(24) where type 24 is ExportAlias(25)). The canonical + // ResourceRep/ResourceNew entries use the target type (25). We need + // the map to also contain the alias source so resolve_resource_positions + // can find the import for either type ID. + let known_resource_types: Vec = map + .keys() + .map(|&(rt, _)| rt) + .collect::>() + .into_iter() + .collect(); + for (idx, def) in component.component_type_defs.iter().enumerate() { + if let crate::parser::ComponentTypeDef::ExportAlias(target) = def { + let alias_id = idx as u32; + let target_id = *target; + for kind in &["[resource-rep]", "[resource-new]"] { + if known_resource_types.contains(&target_id) && !map.contains_key(&(alias_id, kind)) + { + if let Some(entry) = map.get(&(target_id, kind)).cloned() { + map.insert((alias_id, kind), entry); + } + } + if known_resource_types.contains(&alias_id) && !map.contains_key(&(target_id, kind)) + { + if let Some(entry) = map.get(&(alias_id, kind)).cloned() { + map.insert((target_id, kind), entry); + } + } + } + } + } + map } From a101327c105b8e61e63528612d925960efad48f7 Mon Sep 17 00:00:00 2001 From: Ralf Anton Beier Date: Mon, 16 Mar 2026 07:09:49 +0100 Subject: [PATCH 2/2] fix: collapse nested if blocks per clippy Co-Authored-By: Claude Opus 4.6 (1M context) --- meld-core/src/resolver.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/meld-core/src/resolver.rs b/meld-core/src/resolver.rs index e5641cd..bd9ec1f 100644 --- a/meld-core/src/resolver.rs +++ b/meld-core/src/resolver.rs @@ -838,17 +838,17 @@ fn build_resource_type_to_import( let alias_id = idx as u32; let target_id = *target; for kind in &["[resource-rep]", "[resource-new]"] { - if known_resource_types.contains(&target_id) && !map.contains_key(&(alias_id, kind)) + if known_resource_types.contains(&target_id) + && !map.contains_key(&(alias_id, kind)) + && let Some(entry) = map.get(&(target_id, kind)).cloned() { - if let Some(entry) = map.get(&(target_id, kind)).cloned() { - map.insert((alias_id, kind), entry); - } + map.insert((alias_id, kind), entry); } - if known_resource_types.contains(&alias_id) && !map.contains_key(&(target_id, kind)) + if known_resource_types.contains(&alias_id) + && !map.contains_key(&(target_id, kind)) + && let Some(entry) = map.get(&(alias_id, kind)).cloned() { - if let Some(entry) = map.get(&(alias_id, kind)).cloned() { - map.insert((target_id, kind), entry); - } + map.insert((target_id, kind), entry); } } }