From b5a684830d1c16a40d44896276f58c1f19fe2872 Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 5 Dec 2016 03:16:43 +0000 Subject: [PATCH] compiler: fix parsing of TList annotations (fixes #632). --- artiq/compiler/embedding.py | 4 ++-- artiq/test/coredevice/test_embedding.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/artiq/compiler/embedding.py b/artiq/compiler/embedding.py index 4a5208c4a..a697a8ac9 100644 --- a/artiq/compiler/embedding.py +++ b/artiq/compiler/embedding.py @@ -436,14 +436,14 @@ class StitchingASTTypedRewriter(ASTTypedRewriter): if annot.id == "TVar": return types.TVar() elif (isinstance(annot, ast.Call) and - annot.keywords is None and + annot.keywords == [] and annot.starargs is None and annot.kwargs is None and isinstance(annot.func, ast.Name)): if annot.func.id == "TList" and len(annot.args) == 1: elttyp = self.match_annotation(annot.args[0]) if elttyp is not None: - return builtins.TList() + return builtins.TList(elttyp) else: return None diff --git a/artiq/test/coredevice/test_embedding.py b/artiq/test/coredevice/test_embedding.py index 8ad7cef63..f0bd12e45 100644 --- a/artiq/test/coredevice/test_embedding.py +++ b/artiq/test/coredevice/test_embedding.py @@ -211,11 +211,16 @@ class _Annotation(EnvExperiment): def overflow(self, x: TInt64) -> TBool: return (x << 32) != 0 + @kernel + def monomorphize(self, x: TList(TInt32)): + pass + class AnnotationTest(ExperimentCase): def test_annotation(self): exp = self.create(_Annotation) self.assertEqual(exp.overflow(1), True) + exp.monomorphize([]) class _Async(EnvExperiment): def build(self):