Skip to content

Commit

Permalink
compiler: fix parsing of TList annotations (fixes #632).
Browse files Browse the repository at this point in the history
whitequark committed Dec 5, 2016
1 parent 88ad054 commit b5a6848
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions artiq/compiler/embedding.py
Original file line number Diff line number Diff line change
@@ -436,14 +436,14 @@ def match_annotation(self, annot):
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

5 changes: 5 additions & 0 deletions artiq/test/coredevice/test_embedding.py
Original file line number Diff line number Diff line change
@@ -211,11 +211,16 @@ def build(self):
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):

0 comments on commit b5a6848

Please sign in to comment.