Skip to content

[Bug]: Misleading validation error when cond signature doesn't match parent #3296

Open

Description

@croyzor

Description

In some cases, validation raises an error claiming that a hugr contains a type mismatch due to a node with signature: [] -> [], which is misleading and untrue

Steps to Reproduce

Here's an example that produces the error when imported and validated

(hugr 0)

(mod)

(define-func public
  example.cond
  (core.fn
    [(core.adt [[(arithmetic.int.types.int 6)] [(arithmetic.int.types.int 6)]]) (arithmetic.int.types.int 6)]
    [(arithmetic.int.types.int 6)])
  (dfg [%0 %1] [%2]
    (signature
      (core.fn
        [(core.adt [[(arithmetic.int.types.int 6)] [(arithmetic.int.types.int 6)]]) (arithmetic.int.types.int 6)]
        [(arithmetic.int.types.int 6)]))
    (cond [%0 %1] [%2]
      (signature
        (core.fn
          [(core.adt [[(arithmetic.int.types.int 6)] [(arithmetic.int.types.int 6)]])]
          [(arithmetic.int.types.int 6)]))
      (dfg [%3 %4] [%3]
        (signature
          (core.fn [(arithmetic.int.types.int 6) (arithmetic.int.types.int 6)] [(arithmetic.int.types.int 6)])))
      (dfg [%5 %6] [%7]
        (signature
          (core.fn [(arithmetic.int.types.int 6) (arithmetic.int.types.int 6)] [(arithmetic.int.types.int 6)]))
        ((arithmetic.int.iadd 6) [%5 %6] [%7]
          (signature
            (core.fn
              [(arithmetic.int.types.int 6) (arithmetic.int.types.int 6)]
              [(arithmetic.int.types.int 6)])))))))

Expected Behaviour

What is wrong with this hugr is that the signature of cond is wrong: it ignores the second argument (of type (arithmetic.int.types.int 6) that it inherits from the DFG

Actual Behaviour

I get the following error

Error: Package validation error.

Caused by:
    0: An operation Conditional contains invalid children: Case 0 in a conditional has optype `Case : [] -> []`, which differs from the signature of Conditional container: [[int(6)]+[int(6)]] -> [int(6)]. In parent Node(4), child Node(5)
    1: Case 0 in a conditional has optype `Case : [] -> []`, which differs from the signature of Conditional container: [[int(6)]+[int(6)]] -> [int(6)]

which is lies??

Activity

  1. added
    C-bugfixCategory: PR with bug fix
    S-needs-triageStatus: Needs to be labelled
    A-rustArea: Rust code
    D-mediumExperience needed to fix: Medium / intermediate
    P-help-wantedCall for participation: Good issues for third party contributors
    on Oct 9, 2026
  2. self-assigned this
    on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-rustArea: Rust codeC-bugfixCategory: PR with bug fixD-mediumExperience needed to fix: Medium / intermediateP-help-wantedCall for participation: Good issues for third party contributorsS-needs-triageStatus: Needs to be labelled

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions