@@ -183,7 +183,9 @@ impl<'a, H: HugrView> ValidationContext<'a, H> {
183183
184184 let mut links = self . hugr . linked_ports ( node, port) . peekable ( ) ;
185185 // Linear dataflow values must be used, and control must have somewhere to flow.
186- let outgoing_is_linear = port_kind. is_linear ( ) || port_kind == EdgeKind :: ControlFlow ;
186+ let outgoing_is_unique = port_kind. is_linear ( ) || port_kind == EdgeKind :: ControlFlow ;
187+ // All dataflow wires must have a unique source.
188+ let incoming_is_unique = port_kind. is_value ( ) || port_kind. is_const ( ) ;
187189 let must_be_connected = match dir {
188190 // Incoming ports must be connected, except for state order ports, branch case nodes,
189191 // and CFG nodes.
@@ -192,7 +194,7 @@ impl<'a, H: HugrView> ValidationContext<'a, H> {
192194 && port_kind != EdgeKind :: ControlFlow
193195 && op_type. tag ( ) != OpTag :: Case
194196 }
195- Direction :: Outgoing => outgoing_is_linear ,
197+ Direction :: Outgoing => outgoing_is_unique ,
196198 } ;
197199 if must_be_connected && links. peek ( ) . is_none ( ) {
198200 return Err ( ValidationError :: UnconnectedPort {
@@ -204,6 +206,13 @@ impl<'a, H: HugrView> ValidationContext<'a, H> {
204206
205207 // Avoid double checking connected port types.
206208 if dir == Direction :: Incoming {
209+ if incoming_is_unique && links. nth ( 1 ) . is_some ( ) {
210+ return Err ( ValidationError :: TooManyConnections {
211+ node,
212+ port,
213+ port_kind,
214+ } ) ;
215+ }
207216 return Ok ( ( ) ) ;
208217 }
209218
@@ -217,7 +226,7 @@ impl<'a, H: HugrView> ValidationContext<'a, H> {
217226 let mut link_cnt = 0 ;
218227 for ( other_node, other_offset) in links {
219228 link_cnt += 1 ;
220- if outgoing_is_linear && link_cnt > 1 {
229+ if outgoing_is_unique && link_cnt > 1 {
221230 return Err ( ValidationError :: TooManyConnections {
222231 node,
223232 port,
0 commit comments