Handle bound instructions in pattern type inference (#113)

This commit is contained in:
d1m0
2017-07-11 08:39:22 -07:00
committed by Jakob Stoklund Olesen
parent fc11ae7b72
commit f837dcf4b7
2 changed files with 115 additions and 8 deletions

View File

@@ -606,14 +606,19 @@ def ti_def(definition, typ):
expr = definition.expr
inst = expr.inst
# Create a map m mapping each free typevar in the signature of definition
# to a fresh copy of itself
all_formal_tvs = \
[inst.outs[i].typevar for i in inst.value_results] +\
[inst.ins[i].typevar for i in inst.value_opnums]
free_formal_tvs = [tv for tv in all_formal_tvs if not tv.is_derived]
# Create a dict m mapping each free typevar in the signature of definition
# to a fresh copy of itself.
if inst.is_polymorphic:
free_formal_tvs = [inst.ctrl_typevar] + inst.other_typevars
else:
free_formal_tvs = []
m = {tv: tv.get_fresh_copy(str(typ.get_uid())) for tv in free_formal_tvs}
# Update m with any explicitly bound type vars
for (idx, bound_typ) in enumerate(expr.typevars):
m[free_formal_tvs[idx]] = TypeVar.singleton(bound_typ)
# Get fresh copies for each typevar in the signature (both free and
# derived)
fresh_formal_tvs = \