@@ -1405,6 +1405,8 @@ def connect(m, *args, **kwargs):
1405
1405
if not isinstance (m , Module ):
1406
1406
raise TypeError (f"The initial argument must be a module, not { m !r} " )
1407
1407
1408
+ src_loc_at = 1
1409
+
1408
1410
objects = {
1409
1411
** {index : arg for index , arg in enumerate (args )},
1410
1412
** {keyword : arg for keyword , arg in kwargs .items ()}
@@ -1552,7 +1554,7 @@ def connect(m, *args, **kwargs):
1552
1554
# at the beginning of `connect()` passed, and so should casting the result to a Value.
1553
1555
(out_path , out_member ), = out_kind
1554
1556
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 ):
1556
1558
in_value = Value .cast (_traverse_path (in_path , objects ))
1557
1559
out_value = Value .cast (_traverse_path (out_path , objects ))
1558
1560
assert type (in_value ) in (Const , Signal )
@@ -1578,16 +1580,18 @@ def connect_value(*, out_path, in_path):
1578
1580
# been made.
1579
1581
return
1580
1582
# 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 ):
1583
1585
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 )
1585
1587
dimension , * rest_of_dimensions = dimensions
1586
1588
for index in range (dimension ):
1587
1589
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 )
1589
1592
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 )
1591
1595
1592
1596
# If no connections were made, and there were inputs but no outputs in the
1593
1597
# signatures, issue a diagnostic as this is most likely in error.
0 commit comments