mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 03:08:27 +08:00
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":
|
||||
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
|
||||
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user