Skip to content

Commit

Permalink
fix: Do not require matching extension_reqs when creating a replaceme…
Browse files Browse the repository at this point in the history
…nt (#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.
  • Loading branch information
aborgna-q authored Jun 7, 2024
1 parent 6800e68 commit 68595c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hugr-core/src/hugr/views/sibling_subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&current_signature.input)
|| new_signature.as_ref().map(|s| &s.output) != Some(&current_signature.output)
{
return Err(InvalidReplacement::InvalidSignature);
}

Expand Down

0 comments on commit 68595c8

Please sign in to comment.