hdl.ast: clarify exception message for out of bounds indexing.

Fixes #488.
This commit is contained in:
whitequark 2020-08-27 01:14:05 +00:00
parent 5b01499901
commit fde242aa47
2 changed files with 2 additions and 2 deletions

View file

@ -254,7 +254,7 @@ class Value(metaclass=ABCMeta):
n = len(self)
if isinstance(key, int):
if key not in range(-n, n):
raise IndexError("Cannot index {} bits into {}-bit value".format(key, n))
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)