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