hdl.ast: fix src_loc for Slice.

This commit is contained in:
Marcelina Kościelnicka 2023-06-07 17:59:11 +02:00 committed by Catherine
parent 3d3846e996
commit 1b0fb1afbc

View file

@ -277,12 +277,12 @@ class Value(metaclass=ABCMeta):
raise IndexError(f"Index {key} is out of bounds for a {n}-bit value")
if key < 0:
key += n
return Slice(self, key, key + 1)
return Slice(self, key, key + 1, src_loc_at=1)
elif isinstance(key, slice):
start, stop, step = key.indices(n)
if step != 1:
return Cat(self[i] for i in range(start, stop, step))
return Slice(self, start, stop)
return Slice(self, start, stop, src_loc_at=1)
else:
raise TypeError("Cannot index value with {}".format(repr(key)))