hdl.ast: clarify exception message for out of bounds indexing.
[nmigen.git] / nmigen / hdl / ast.py
index 7d2efef1c94f5ab76851c9dc53beebbdfa4f07c7..4a01bde32b2da347d153fd3804ee629e68c7fcbf 100644 (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)