@@ -1405,6 +1405,8 @@ def connect(m, *args, **kwargs):
14051405 if not isinstance (m , Module ):
14061406 raise TypeError (f"The initial argument must be a module, not { m !r} " )
14071407
1408+ src_loc_at = 1
1409+
14081410 objects = {
14091411 ** {index : arg for index , arg in enumerate (args )},
14101412 ** {keyword : arg for keyword , arg in kwargs .items ()}
@@ -1552,7 +1554,7 @@ def connect(m, *args, **kwargs):
15521554 # at the beginning of `connect()` passed, and so should casting the result to a Value.
15531555 (out_path , out_member ), = out_kind
15541556 for (in_path , in_member ) in in_kind :
1555- def connect_value (* , out_path , in_path ):
1557+ def connect_value (* , out_path , in_path , src_loc_at ):
15561558 in_value = Value .cast (_traverse_path (in_path , objects ))
15571559 out_value = Value .cast (_traverse_path (out_path , objects ))
15581560 assert type (in_value ) in (Const , Signal )
@@ -1578,16 +1580,18 @@ def connect_value(*, out_path, in_path):
15781580 # been made.
15791581 return
15801582 # A connection that is made at this point is guaranteed to be valid.
1581- connections .append (in_value .eq (out_value ))
1582- def connect_dimensions (dimensions , * , out_path , in_path ):
1583+ connections .append (in_value .eq (out_value , src_loc_at = src_loc_at + 1 ))
1584+ def connect_dimensions (dimensions , * , out_path , in_path , src_loc_at ):
15831585 if not dimensions :
1584- return connect_value (out_path = out_path , in_path = in_path )
1586+ return connect_value (out_path = out_path , in_path = in_path , src_loc_at = src_loc_at )
15851587 dimension , * rest_of_dimensions = dimensions
15861588 for index in range (dimension ):
15871589 connect_dimensions (rest_of_dimensions ,
1588- out_path = (* out_path , index ), in_path = (* in_path , index ))
1590+ out_path = (* out_path , index ), in_path = (* in_path , index ),
1591+ src_loc_at = src_loc_at + 1 )
15891592 assert out_member .dimensions == in_member .dimensions
1590- connect_dimensions (out_member .dimensions , out_path = out_path , in_path = in_path )
1593+ connect_dimensions (out_member .dimensions ,
1594+ out_path = out_path , in_path = in_path , src_loc_at = src_loc_at + 1 )
15911595
15921596 # If no connections were made, and there were inputs but no outputs in the
15931597 # signatures, issue a diagnostic as this is most likely in error.
0 commit comments