You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if this is something we want to support, since a workaround is to just call int on the BV index value (but then maybe we should add an error check).
def __setitem__(self, index, value):
if isinstance(index, slice):
raise NotImplementedError()
else:
if not (isinstance(value, bool) or isinstance(value, Bit) or (isinstanc
e(value, int) and value in {0, 1})):
raise ValueError("Second argument __setitem__ on a single BitVector
index should be a boolean or 0 or 1, not {value}".format(value=value))
if index < 0:
index = self.size+index
if not (0 <= index < self.size):
> raise IndexError()
E IndexError
The reason is that when doing idx < self.size we get an overflow in the less than operator, so it always evaluates to false (since no BV[2] will be less than 0), here's an example:
Generally using a BitVector as a key to set/getitem like this is probably problematic for general objects (since I'd imagine most interfaces expect an int type that will certainly behave differently than a BV in some cases)
Not sure if this is something we want to support, since a workaround is to just call
int
on the BV index value (but then maybe we should add an error check).Here's an example:
This will always raise the following error:
The reason is that when doing
idx < self.size
we get an overflow in the less than operator, so it always evaluates to false (since no BV[2] will be less than 0), here's an example:will produce
If we want to support a BV index, we probably just need to do some extension logic to catch the overflow case in the comparison.
The text was updated successfully, but these errors were encountered: