Fix up stacks for type checking.

Sometimes (e.g. 'clear') the () at the end of the stack was tripping up
the unify() function.
This commit is contained in:
Simon Forman 2018-07-15 13:57:11 -07:00
parent e169c6aae2
commit 20d87db9d5
1 changed files with 12 additions and 0 deletions

View File

@ -355,6 +355,8 @@ def type_check(name, stack):
except KeyError:
return # None, indicating unknown
stack = _foo_stack(stack)
for fi, fo in infer(func):
try:
U = unify(fi, stack)
@ -369,6 +371,16 @@ def type_check(name, stack):
return False
def _foo_stack(stack, s=None):
if s is None:
s = (StackJoyType(n) for n in xrange(23, 100))
if stack == ():
return next(s)
if isinstance(stack, tuple):
return tuple(_foo_stack(inner, s) for inner in stack)
return stack
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9 = A
b0, b1, b2, b3, b4, b5, b6, b7, b8, b9 = B
n0, n1, n2, n3, n4, n5, n6, n7, n8, n9 = N