From 4b01e604dbd606164161747bd9cc076181adcb83 Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 4 Jun 2015 14:50:16 +0300 Subject: [PATCH] Make unification reflective. --- artiq/py2llvm/types.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/artiq/py2llvm/types.py b/artiq/py2llvm/types.py index ff17c8456..dc15c5cb5 100644 --- a/artiq/py2llvm/types.py +++ b/artiq/py2llvm/types.py @@ -80,6 +80,8 @@ class TMono(Type): assert self.params.keys() == other.params.keys() for param in self.params: self.params[param].unify(other.params[param]) + elif isinstance(other, TVar): + other.unify(self) else: raise UnificationError(self, other) @@ -110,6 +112,8 @@ class TTuple(Type): if isinstance(other, TTuple) and len(self.elts) == len(other.elts): for selfelt, otherelt in zip(self.elts, other.elts): selfelt.unify(otherelt) + elif isinstance(other, TVar): + other.unify(self) else: raise UnificationError(self, other) @@ -136,7 +140,9 @@ class TValue(Type): return self def unify(self, other): - if self != other: + if isinstance(other, TVar): + other.unify(self) + elif self != other: raise UnificationError(self, other) def __repr__(self):