The following code should verify, but at least one assertion fails:
from nagini_contracts.contracts import *
from typing import Union, List
def test_union_function(u: Union[List[int], int]) -> None:
Requires(Implies(isinstance(u, list), list_pred(u)))
if not u:
if isinstance(u, int):
assert u == 0
else:
assert len(u) == 0
The problem seems to be that if not u gets translated to if (!object___bool__(u)) instead of something like if (!(isinstance(u, int) ? int___bool__(u) : list___bool__(u))). My guess would be that we would have a similar problem in other situations where self.get_function_call is used internally.
The following code should verify, but at least one assertion fails:
The problem seems to be that
if not u
gets translated toif (!object___bool__(u))
instead of something likeif (!(isinstance(u, int) ? int___bool__(u) : list___bool__(u)))
. My guess would be that we would have a similar problem in other situations whereself.get_function_call
is used internally.