From 5d40c2431e94a90df518b0b0153ae02f12a748cb Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 19 Dec 2014 15:19:59 +0800 Subject: [PATCH] py2llvm: support type merge with empty list --- artiq/py2llvm/ast_body.py | 2 +- artiq/py2llvm/lists.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/artiq/py2llvm/ast_body.py b/artiq/py2llvm/ast_body.py index 306ffb821..3cba3a976 100644 --- a/artiq/py2llvm/ast_body.py +++ b/artiq/py2llvm/ast_body.py @@ -200,7 +200,7 @@ class Visitor: for elt in elts[1:]: el_type.merge(elt) else: - el_type = VNone() + el_type = base_types.VNone() count = len(elts) r = lists.VList(el_type, count) r.elts = elts diff --git a/artiq/py2llvm/lists.py b/artiq/py2llvm/lists.py index 14e59622d..ded97773e 100644 --- a/artiq/py2llvm/lists.py +++ b/artiq/py2llvm/lists.py @@ -30,7 +30,14 @@ class VList(VGeneric): def merge(self, other): if isinstance(other, VList): - self.el_type.merge(other.el_type) + if self.alloc_count: + if other.alloc_count: + self.el_type.merge(other.el_type) + if self.alloc_count < other.alloc_count: + self.alloc_count = other.alloc_count + else: + self.el_type = other.el_type.new() + self.alloc_count = other.alloc_count else: raise TypeError("Incompatible types: {} and {}" .format(repr(self), repr(other)))