hdl.ast: raise a sensible error for xxx in Value
This commit is contained in:
parent
86d14f584e
commit
bf8faea51e
|
@ -377,6 +377,9 @@ class Value(metaclass=ABCMeta):
|
|||
else:
|
||||
raise TypeError(f"Cannot index value with {key!r}")
|
||||
|
||||
def __contains__(self, other):
|
||||
raise TypeError("Cannot use 'in' with an Amaranth value")
|
||||
|
||||
def as_unsigned(self):
|
||||
"""Conversion to unsigned.
|
||||
|
||||
|
|
|
@ -750,6 +750,11 @@ class OperatorTestCase(FHDLTestCase):
|
|||
""")
|
||||
self.assertEqual(abs(s).shape(), unsigned(4))
|
||||
|
||||
def test_contains(self):
|
||||
with self.assertRaisesRegex(TypeError,
|
||||
r"^Cannot use 'in' with an Amaranth value$"):
|
||||
1 in Signal(3)
|
||||
|
||||
|
||||
class SliceTestCase(FHDLTestCase):
|
||||
def test_shape(self):
|
||||
|
|
Loading…
Reference in a new issue