I have the following code, and its type is (not) being inferred in a very bizarre fashion.
What's confusing is that this is not just a typical failure of the engine to infer types, but rather it's exhibiting such strange behavior that I cannot even understand where or what the bug might be.
Can someone explain what is going on? Why do the order and the presence of the statements that assign to x
, y
, and z
affect the types of each other?
(For your convenience, I've added a suffix indicating the inferred type, so z1__int
is inferred as int
.)
def lmap1(func, items):
return [func(item1) for item1 in items]
def tmap(f, items):
return tuple(lmap1(f, items))
def a():
f = lambda i: i
items = [1]
x1__unknown = tmap(f, items)[0]
y1__unknown = tuple(lmap1(f, items))[0]
z1__int = tuple([f(item1) for item1 in items])[0]
def b():
f = lambda i: i
items = [1]
y2__int = tuple(lmap1(f, items))[0]
x2__unknown = tmap(f, items)[0]
z2__int = tuple([f(item1) for item1 in items])[0]
def c():
f = lambda i: i
items = [1]
y3__unknown = tuple(lmap1(f, items))[0]
x1__unknown = tmap(f, items)[0]