mirror of https://github.com/m-labs/artiq.git
compiler: do not try to re-coerce fully coerced numerics.
This commit is contained in:
parent
742e273441
commit
58967f14fd
|
@ -310,7 +310,15 @@ class Inferencer(algorithm.Visitor):
|
||||||
node_types = []
|
node_types = []
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
if isinstance(node, asttyped.CoerceT):
|
if isinstance(node, asttyped.CoerceT):
|
||||||
node_types.append(node.value.type)
|
# If we already know exactly what we coerce this value to, use that type,
|
||||||
|
# or we'll get an unification error in case the coerced type is not the same
|
||||||
|
# as the type of the coerced value.
|
||||||
|
# Otherwise, use the potentially more specific subtype when considering possible
|
||||||
|
# coercions, or we may get stuck.
|
||||||
|
if node.type.fold(False, lambda acc, ty: acc or types.is_var(ty)):
|
||||||
|
node_types.append(node.value.type)
|
||||||
|
else:
|
||||||
|
node_types.append(node.type)
|
||||||
else:
|
else:
|
||||||
node_types.append(node.type)
|
node_types.append(node.type)
|
||||||
if any(map(types.is_var, node_types)): # not enough info yet
|
if any(map(types.is_var, node_types)): # not enough info yet
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
# RUN: %python -m artiq.compiler.testbench.inferencer +mono %s >%t
|
||||||
|
# RUN: OutputCheck %s --file-to-check=%t
|
||||||
|
|
||||||
|
# CHECK-L: n:numpy.int32 =
|
||||||
|
n = 0
|
||||||
|
# CHECK-L: a:numpy.int32 =
|
||||||
|
a = n // 1
|
||||||
|
# CHECK-L: b:numpy.int32 =
|
||||||
|
b = n // 10
|
||||||
|
# CHECK-L: q:numpy.int64 =
|
||||||
|
q = (a << 0) + (b << 8)
|
||||||
|
core_log(int64(q))
|
Loading…
Reference in New Issue