forked from M-Labs/artiq
py2llvm: support type merge with empty list
This commit is contained in:
parent
a9b28dff36
commit
5d40c2431e
|
@ -200,7 +200,7 @@ class Visitor:
|
||||||
for elt in elts[1:]:
|
for elt in elts[1:]:
|
||||||
el_type.merge(elt)
|
el_type.merge(elt)
|
||||||
else:
|
else:
|
||||||
el_type = VNone()
|
el_type = base_types.VNone()
|
||||||
count = len(elts)
|
count = len(elts)
|
||||||
r = lists.VList(el_type, count)
|
r = lists.VList(el_type, count)
|
||||||
r.elts = elts
|
r.elts = elts
|
||||||
|
|
|
@ -30,7 +30,14 @@ class VList(VGeneric):
|
||||||
|
|
||||||
def merge(self, other):
|
def merge(self, other):
|
||||||
if isinstance(other, VList):
|
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:
|
else:
|
||||||
raise TypeError("Incompatible types: {} and {}"
|
raise TypeError("Incompatible types: {} and {}"
|
||||||
.format(repr(self), repr(other)))
|
.format(repr(self), repr(other)))
|
||||||
|
|
Loading…
Reference in New Issue