andreinaku / SpyType

MIT License
0 stars 0 forks source link

instatiate spec for var args #41

Open andreinaku opened 2 months ago

andreinaku commented 2 months ago

func spec

    'waldo': {
        r'((__va_args:Iterable < T?1 > /\ __kw_kwargs:Iterable < T?2 >) -> (return:bool))',
    },

func call:

waldo(a, b, c=x, d=y):bool)

current instantiation:

((a:T?1 /\ b:T?1 /\ x:T?2 /\ y:T?2) -> (waldo(a, b, c=x, d=y):bool))

This does not work for a current state like this: (a:float /\ b:int /\ x:float /\ y:str). Why? Because it would lead to the conjunction (T?1 <= float) /\ (T?1 <= int)), which means that both T?1 |-> int and T?1 |-> float occur, which results in T?1 |-> bot, which generates an invalid state. And this means that the specification cannot be applied.

desired instantiation:

((a, b): Iterable < T?1 > /\ (x, y): Iterable < T?2 >) -> (waldo(a, b, c=x, d=y):bool))

This is actually what happens in this case. What is needed for this approach is to have (a, b) and (x, y) in the current state. Therefore, the current state must be modified as follows:

(a:float /\ b:int /\ x:float /\ y:str /\ (a, b):tuple < int + float > /\ (x, y):tuple < float + str >)