Skip to content

Commit

Permalink
fix: No dataflow_signature for block types (#792)
Browse files Browse the repository at this point in the history
Basic blocks should not have a `dataflow_signature`, they have no
dataflow ports! But, for DataflowBlock, implement `extension_delta`
instead (and fix replace.rs test correspondingly)
  • Loading branch information
acl-cqc authored Jan 8, 2024
1 parent 2b7de5d commit d07406c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/hugr/rewrite/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,9 @@ mod test {
inputs: vec![listy.clone()].into(),
tuple_sum_rows: vec![type_row![]],
other_outputs: vec![listy.clone()].into(),
extension_delta: ExtensionSet::singleton(&collections::EXTENSION_NAME),
// This should be ExtensionSet::singleton(&collections::EXTENSION_NAME),
// at least when https://github.com/CQCL/issues/388 is fixed
extension_delta: ExtensionSet::new(),
},
)?;
let r_df1 = replacement.add_node_with_parent(
Expand Down
12 changes: 3 additions & 9 deletions src/ops/controlflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use smol_str::SmolStr;

use crate::extension::ExtensionSet;
use crate::types::{EdgeKind, FunctionType, Type, TypeRow};
use crate::{type_row, Direction};
use crate::Direction;

use super::dataflow::{DataflowOpTrait, DataflowParent};
use super::OpTag;
Expand Down Expand Up @@ -179,10 +179,8 @@ impl OpTrait for DataflowBlock {
Some(EdgeKind::ControlFlow)
}

fn dataflow_signature(&self) -> Option<FunctionType> {
Some(
FunctionType::new(type_row![], type_row![]).with_extension_delta(&self.extension_delta),
)
fn extension_delta(&self) -> ExtensionSet {
self.extension_delta.clone()
}

fn non_df_port_count(&self, dir: Direction) -> usize {
Expand Down Expand Up @@ -210,10 +208,6 @@ impl OpTrait for ExitBlock {
Some(EdgeKind::ControlFlow)
}

fn dataflow_signature(&self) -> Option<FunctionType> {
Some(FunctionType::new(type_row![], type_row![]))
}

fn non_df_port_count(&self, dir: Direction) -> usize {
match dir {
Direction::Incoming => 1,
Expand Down

0 comments on commit d07406c

Please sign in to comment.