Skip to content

hugr-py: Hugr.num_out_ports gives invalid results for function definitions constructed using the builder #2438

@mark-koch

Description

@mark-koch
from hugr.build import Function
from hugr import tys, ops

mod = Module()
main = mod.define_function("main", [], 4 * [tys.Unit])
unit = main.add_op(ops.MakeTuple())
main.set_outputs(*4*[unit])
print(mod.hugr.num_out_ports(main))

This should output 1 (function defns have one outport), but we get 4. It looks like we mistakenly use the inner signature.

Potential fix is to stop calling _set_parent_output_count in Function.declare_outputs

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