py2llvm: support type merge with empty list

This commit is contained in:
Sebastien Bourdeauducq 2014-12-19 15:19:59 +08:00
parent a9b28dff36
commit 5d40c2431e
2 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -30,7 +30,14 @@ class VList(VGeneric):
def merge(self, other):
if isinstance(other, VList):
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)))