Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hugr-core/src/ops/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pub struct CallIndirect {
impl_op_name!(CallIndirect);

impl DataflowOpTrait for CallIndirect {
const TAG: OpTag = OpTag::FnCall;
const TAG: OpTag = OpTag::DataflowChild;

fn description(&self) -> &str {
"Call a function indirectly"
Expand Down
28 changes: 27 additions & 1 deletion hugr-passes/src/force_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ mod test {
use hugr_core::builder::{endo_sig, BuildHandle, Dataflow, DataflowHugr};
use hugr_core::ops::handle::{DataflowOpID, NodeHandle};

use hugr_core::ops::Value;
use hugr_core::ops::{self, Value};
use hugr_core::std_extensions::arithmetic::int_ops::IntOpDef;
use hugr_core::std_extensions::arithmetic::int_types::INT_TYPES;
use hugr_core::types::{Signature, Type};
Expand Down Expand Up @@ -326,4 +326,30 @@ mod test {
let root = hugr.root();
force_order(&mut hugr, root, |_, _| 0).unwrap();
}

#[test]
/// test for https://github.com/CQCL/hugr/issues/2005
fn call_indirect_bug() {
let fn_type = Signature::new(Type::UNIT, vec![Type::UNIT]);
let mut hugr = {
let mut builder = DFGBuilder::new(Signature::new(
vec![Type::new_function(fn_type.clone()), Type::UNIT],
vec![Type::UNIT, Type::UNIT],
))
.unwrap();
let out = builder
.add_dataflow_op(
ops::CallIndirect { signature: fn_type },
builder.input_wires(),
)
.unwrap()
.out_wire(0);
// requires another op to induce an order edge
let other_unit = builder.add_load_value(Value::unary_unit_sum());
builder.finish_hugr_with_outputs([out, other_unit]).unwrap()
};
let root = hugr.root();

force_order(&mut hugr, root, |_, _| 0).unwrap();
}
}
Loading