Skip to content

Commit

Permalink
fix: incorrect typevar use in _get_typed_op
Browse files Browse the repository at this point in the history
  • Loading branch information
ss2165 committed Jun 18, 2024
1 parent 85855de commit 80e6832
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 1 addition & 3 deletions hugr-py/src/hugr/_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ def branch_exit(self, src: Wire) -> None:
src = src.out_port()
self.hugr.add_link(src, self.exit.inp(0))

src_block: ops.DataflowBlock = self.hugr._get_typed_op(
src.node, ops.DataflowBlock
)
src_block = self.hugr._get_typed_op(src.node, ops.DataflowBlock)
out_types = src_block.nth_outputs(src.offset)
if self._exit_op._cfg_outputs is not None:
if self._exit_op._cfg_outputs != out_types:
Expand Down
3 changes: 2 additions & 1 deletion hugr-py/src/hugr/_hugr.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def to_serial(self, node: Node, hugr: Hugr) -> SerialOp:
P = TypeVar("P", InPort, OutPort)
K = TypeVar("K", InPort, OutPort)
OpVar = TypeVar("OpVar", bound=Op)
OpVar2 = TypeVar("OpVar2", bound=Op)


@dataclass(frozen=True, eq=True, order=True)
Expand Down Expand Up @@ -189,7 +190,7 @@ def __iter__(self):
def __len__(self) -> int:
return self.num_nodes()

def _get_typed_op(self, node: ToNode, cl: PyType[OpVar]) -> OpVar:
def _get_typed_op(self, node: ToNode, cl: PyType[OpVar2]) -> OpVar2:
op = self[node].op
assert isinstance(op, cl)
return op
Expand Down

0 comments on commit 80e6832

Please sign in to comment.