diff --git a/src/builder/build_traits.rs b/src/builder/build_traits.rs index e3c0f6671..3a122eb8b 100644 --- a/src/builder/build_traits.rs +++ b/src/builder/build_traits.rs @@ -200,7 +200,7 @@ pub trait Dataflow: Container { op: impl Into, input_wires: impl IntoIterator, ) -> Result, BuildError> { - self.add_dataflow_node(NodeType::new_open(op), input_wires) + self.add_dataflow_node(NodeType::new_default(op), input_wires) } /// Add a dataflow [`NodeType`] to the sibling graph, wiring up the `input_wires` to the @@ -628,7 +628,7 @@ fn add_op_with_wires( optype: impl Into, inputs: Vec, ) -> Result<(Node, usize), BuildError> { - add_node_with_wires(data_builder, NodeType::new_open(optype), inputs) + add_node_with_wires(data_builder, NodeType::new_default(optype), inputs) } fn add_node_with_wires( diff --git a/src/extension/infer.rs b/src/extension/infer.rs index 46f2c0cad..d3fa0fa63 100644 --- a/src/extension/infer.rs +++ b/src/extension/infer.rs @@ -316,9 +316,6 @@ impl UnificationContext { m_output, node_type.op_signature().extension_reqs, ); - if OpTag::ModuleOp.is_superset(node_type.tag()) { - self.add_solution(m_input, ExtensionSet::new()); - } } // We have a solution for everything! Some(sig) => { diff --git a/src/hugr.rs b/src/hugr.rs index c1acfb1fd..deccdada1 100644 --- a/src/hugr.rs +++ b/src/hugr.rs @@ -98,6 +98,17 @@ impl NodeType { } } + /// Instantiate an [OpType] with the default set of input extensions + /// for that OpType. + pub fn new_default(op: impl Into) -> Self { + let op = op.into(); + if OpTag::ModuleOp.is_superset(op.tag()) { + Self::new_pure(op) + } else { + Self::new_open(op) + } + } + /// Use the input extensions to calculate the concrete signature of the node pub fn signature(&self) -> Option { self.input_extensions @@ -237,7 +248,7 @@ impl Hugr { /// Add a node to the graph, with the default conversion from OpType to NodeType pub(crate) fn add_op(&mut self, op: impl Into) -> Node { - self.add_node(NodeType::new_open(op)) + self.add_node(NodeType::new_default(op)) } /// Add a node to the graph. diff --git a/src/hugr/hugrmut.rs b/src/hugr/hugrmut.rs index 52f47b309..7e066d1cb 100644 --- a/src/hugr/hugrmut.rs +++ b/src/hugr/hugrmut.rs @@ -37,7 +37,7 @@ pub trait HugrMut: HugrMutInternals { parent: Node, op: impl Into, ) -> Result { - self.add_node_with_parent(parent, NodeType::new_open(op)) + self.add_node_with_parent(parent, NodeType::new_default(op)) } /// Add a node to the graph with a parent in the hierarchy. @@ -217,7 +217,7 @@ impl + AsMut> HugrMut for T { } fn add_op_before(&mut self, sibling: Node, op: impl Into) -> Result { - self.add_node_before(sibling, NodeType::new_open(op)) + self.add_node_before(sibling, NodeType::new_default(op)) } fn add_node_before(&mut self, sibling: Node, nodetype: NodeType) -> Result {