Skip to content

hugr-py: Hugr.add_order_link breaks if source node has unconnected ports #2439

@mark-koch

Description

@mark-koch
from hugr import tys
from hugr.build import Dfg
from tket2_exts import quantum

QUANTUM_EXT = quantum()

dfg = Dfg(tys.Qubit)
meas = dfg.add_op(QUANTUM_EXT.get_op("MeasureFree").instantiate(), *dfg.inputs())
alloc = dfg.add_op(QUANTUM_EXT.get_op("QAlloc").instantiate())
dfg.hugr.add_order_link(meas, alloc)
dfg.set_outputs(alloc)

Validation fails with

Connected ports Port(Outgoing, 0) in Node(7) and Port(Incoming, 0) in Node(8) have incompatible kinds. Cannot connect bool to StateOrder.

The state order source is mistakenly attached to the bool output of the MeasureFree op.

This causes a bug in Guppy: #1092

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpythonPull requests that update Python code

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions