Skip to content

Commit

Permalink
Update required port connection test
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Jun 23, 2023
1 parent 81ab922 commit 35b3958
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/hugr/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,16 @@ impl<'a> ValidationContext<'a> {
let port_kind = optype.port_kind(port).unwrap();
let dir = port.direction();

// Input ports and output linear ports must always be connected
let mut links = self.hugr.graph.port_links(port_index).peekable();
let must_be_connected = match dir {
// Incoming ports must be connected, except for state order ports, branch case nodes,
// and CFG nodes.
Direction::Incoming => {
port_kind.is_linear() || matches!(port_kind, EdgeKind::Static(_))
port_kind != EdgeKind::StateOrder
&& port_kind != EdgeKind::ControlFlow
&& optype.tag() != OpTag::Case
}
// Linear dataflow values must be connected.
Direction::Outgoing => port_kind.is_linear(),
};
if must_be_connected && links.peek().is_none() {
Expand Down

0 comments on commit 35b3958

Please sign in to comment.