forked from M-Labs/artiq
compiler: fix parsing of TList annotations (fixes #632).
This commit is contained in:
parent
88ad054ab6
commit
b5a684830d
|
@ -436,14 +436,14 @@ class StitchingASTTypedRewriter(ASTTypedRewriter):
|
||||||
if annot.id == "TVar":
|
if annot.id == "TVar":
|
||||||
return types.TVar()
|
return types.TVar()
|
||||||
elif (isinstance(annot, ast.Call) and
|
elif (isinstance(annot, ast.Call) and
|
||||||
annot.keywords is None and
|
annot.keywords == [] and
|
||||||
annot.starargs is None and
|
annot.starargs is None and
|
||||||
annot.kwargs is None and
|
annot.kwargs is None and
|
||||||
isinstance(annot.func, ast.Name)):
|
isinstance(annot.func, ast.Name)):
|
||||||
if annot.func.id == "TList" and len(annot.args) == 1:
|
if annot.func.id == "TList" and len(annot.args) == 1:
|
||||||
elttyp = self.match_annotation(annot.args[0])
|
elttyp = self.match_annotation(annot.args[0])
|
||||||
if elttyp is not None:
|
if elttyp is not None:
|
||||||
return builtins.TList()
|
return builtins.TList(elttyp)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -211,11 +211,16 @@ class _Annotation(EnvExperiment):
|
||||||
def overflow(self, x: TInt64) -> TBool:
|
def overflow(self, x: TInt64) -> TBool:
|
||||||
return (x << 32) != 0
|
return (x << 32) != 0
|
||||||
|
|
||||||
|
@kernel
|
||||||
|
def monomorphize(self, x: TList(TInt32)):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class AnnotationTest(ExperimentCase):
|
class AnnotationTest(ExperimentCase):
|
||||||
def test_annotation(self):
|
def test_annotation(self):
|
||||||
exp = self.create(_Annotation)
|
exp = self.create(_Annotation)
|
||||||
self.assertEqual(exp.overflow(1), True)
|
self.assertEqual(exp.overflow(1), True)
|
||||||
|
exp.monomorphize([])
|
||||||
|
|
||||||
class _Async(EnvExperiment):
|
class _Async(EnvExperiment):
|
||||||
def build(self):
|
def build(self):
|
||||||
|
|
Loading…
Reference in New Issue