@@ -1408,6 +1408,8 @@ def connect(m, *args, **kwargs):
14081408 if not isinstance (m , Module ):
14091409 raise TypeError (f"The initial argument must be a module, not { m !r} " )
14101410
1411+ src_loc_at = 1
1412+
14111413 objects = {
14121414 ** {index : arg for index , arg in enumerate (args )},
14131415 ** {keyword : arg for keyword , arg in kwargs .items ()}
@@ -1555,7 +1557,7 @@ def connect(m, *args, **kwargs):
15551557 # at the beginning of `connect()` passed, and so should casting the result to a Value.
15561558 (out_path , out_member ), = out_kind
15571559 for (in_path , in_member ) in in_kind :
1558- def connect_value (* , out_path , in_path ):
1560+ def connect_value (* , out_path , in_path , src_loc_at ):
15591561 in_value = Value .cast (_traverse_path (in_path , objects ))
15601562 out_value = Value .cast (_traverse_path (out_path , objects ))
15611563 assert type (in_value ) in (Const , Signal )
@@ -1581,16 +1583,18 @@ def connect_value(*, out_path, in_path):
15811583 # been made.
15821584 return
15831585 # A connection that is made at this point is guaranteed to be valid.
1584- connections .append (in_value .eq (out_value ))
1585- def connect_dimensions (dimensions , * , out_path , in_path ):
1586+ connections .append (in_value .eq (out_value , src_loc_at = src_loc_at + 1 ))
1587+ def connect_dimensions (dimensions , * , out_path , in_path , src_loc_at ):
15861588 if not dimensions :
1587- return connect_value (out_path = out_path , in_path = in_path )
1589+ return connect_value (out_path = out_path , in_path = in_path , src_loc_at = src_loc_at )
15881590 dimension , * rest_of_dimensions = dimensions
15891591 for index in range (dimension ):
15901592 connect_dimensions (rest_of_dimensions ,
1591- out_path = (* out_path , index ), in_path = (* in_path , index ))
1593+ out_path = (* out_path , index ), in_path = (* in_path , index ),
1594+ src_loc_at = src_loc_at + 1 )
15921595 assert out_member .dimensions == in_member .dimensions
1593- connect_dimensions (out_member .dimensions , out_path = out_path , in_path = in_path )
1596+ connect_dimensions (out_member .dimensions ,
1597+ out_path = out_path , in_path = in_path , src_loc_at = src_loc_at + 1 )
15941598
15951599 # If no connections were made, and there were inputs but no outputs in the
15961600 # signatures, issue a diagnostic as this is most likely in error.
0 commit comments