forked from M-Labs/artiq
compiler: Fix type inference in slice expressions
This was a long-standing issue affecting both lists and the new NumPy array implementation, just caused by the generic inference passes not being run on the slice subexpressions (and thus e.g. ints not being monomorphized). GitHub: Fixes #1632.
This commit is contained in:
parent
75c255425d
commit
557671b7db
|
@ -216,6 +216,7 @@ class Inferencer(algorithm.Visitor):
|
|||
value.loc, None)
|
||||
|
||||
def visit_SliceT(self, node):
|
||||
self.generic_visit(node)
|
||||
if (node.lower, node.upper, node.step) == (None, None, None):
|
||||
self._unify(node.type, builtins.TInt32(),
|
||||
node.loc, None)
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# RUN: %python -m artiq.compiler.testbench.embedding %s
|
||||
|
||||
from artiq.language.core import *
|
||||
from artiq.language.types import *
|
||||
import numpy as np
|
||||
|
||||
class A:
|
||||
def __init__(self):
|
||||
self.n = 2
|
||||
|
||||
@kernel
|
||||
def run(self):
|
||||
print([1, 2, 3][:self.n])
|
||||
|
||||
a = A()
|
||||
|
||||
@kernel
|
||||
def entrypoint():
|
||||
a.run()
|
Loading…
Reference in New Issue