compiler: fix parsing of TList annotations (fixes #632).

This commit is contained in:
whitequark 2016-12-05 03:16:43 +00:00
parent 88ad054ab6
commit b5a684830d
2 changed files with 7 additions and 2 deletions

View File

@ -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

View File

@ -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):