CQCL / hugr

Hierarchical Unified Graph Representation
https://crates.io/crates/hugr
Apache License 2.0
15 stars 4 forks source link

machinery in `simple_op.rs` doesn't check extension #1241

Open doug-q opened 1 week ago

doug-q commented 1 week ago

I am working with two ops:

when I have a lazy.Measure op then Tk2Op::try_from(op) succeeds erroneously.

This is because the impl MakeOpDef for Tk2Op has

    fn from_def(op_def: &OpDef) -> Result<Self, hugr::extension::simple_op::OpLoadError> {
        try_from_name(op_def.name())
    }

This function should check that the extension of op_def is correct.

I am creating the issue here because I think the simple_op.rs machinery should take care of this, perhaps adding fn extension to NamedOp?