expr: use const-ness for put checking in CompExpr
This commit is contained in:
parent
02f53b5096
commit
2294d992cf
|
@ -246,15 +246,16 @@ class CompExpr(Expr[bool]):
|
|||
return self.__op(peek(self.__left, pop=pop), peek(self.__right, pop=pop))
|
||||
|
||||
def _sx_put_(self, value: bool, pop: bool = True) -> None:
|
||||
if not isinstance(self.__left, BaseExpr):
|
||||
if is_const(self.__left):
|
||||
operand = self.__left
|
||||
target = self.__right
|
||||
elif not isinstance(self.__right, BaseExpr):
|
||||
elif is_const(self.__right):
|
||||
operand = self.__right
|
||||
target = self.__left
|
||||
else:
|
||||
raise NotImplementedError(f'{self.__class__.__name__} has two expression operands and is not invertible')
|
||||
raise NotImplementedError(f'{self.__class__.__name__} has two non-const expression operands and is not invertible')
|
||||
|
||||
operand = get(operand, pop=pop)
|
||||
if self.__op == operator.eq and value:
|
||||
value = operand
|
||||
elif self.__op == operator.ne and not value:
|
||||
|
|
Loading…
Reference in New Issue