From 68595c8a776b7a789a078f3c6d5f7ed384f97901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= <121866228+aborgna-q@users.noreply.github.com> Date: Fri, 7 Jun 2024 13:10:57 +0100 Subject: [PATCH] fix: Do not require matching extension_reqs when creating a replacement (#1177) Fixes #1175 Signatures have three components: - The input type row - The output type row - The set of extensions used by the local operations Many interesting replacements in a graph changes the latter, but `SiblingSubgraph::create_simple_replacement` required the signatures to match exactly. --- hugr-core/src/hugr/views/sibling_subgraph.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hugr-core/src/hugr/views/sibling_subgraph.rs b/hugr-core/src/hugr/views/sibling_subgraph.rs index ddc307509..a024bcc17 100644 --- a/hugr-core/src/hugr/views/sibling_subgraph.rs +++ b/hugr-core/src/hugr/views/sibling_subgraph.rs @@ -345,7 +345,12 @@ impl SiblingSubgraph { let Some([rep_input, rep_output]) = replacement.get_io(rep_root) else { return Err(InvalidReplacement::InvalidDataflowParent); }; - if dfg_optype.dataflow_signature() != Some(self.signature(hugr)) { + + let current_signature = self.signature(hugr); + let new_signature = dfg_optype.dataflow_signature(); + if new_signature.as_ref().map(|s| &s.input) != Some(¤t_signature.input) + || new_signature.as_ref().map(|s| &s.output) != Some(¤t_signature.output) + { return Err(InvalidReplacement::InvalidSignature); }