From 77adf2f6b557fb866bda54eeef3aae6002be5507 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sun, 14 Jun 2015 23:13:41 +0300 Subject: [PATCH] Add support for With. --- artiq/py2llvm/typing.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/artiq/py2llvm/typing.py b/artiq/py2llvm/typing.py index a52041275..5e2c498fc 100644 --- a/artiq/py2llvm/typing.py +++ b/artiq/py2llvm/typing.py @@ -312,7 +312,6 @@ class ASTTypedRewriter(algorithm.Transformer): visit_Import = visit_unsupported visit_ImportFrom = visit_unsupported visit_Try = visit_unsupported - visit_With = visit_unsupported class Inferencer(algorithm.Visitor): @@ -725,6 +724,15 @@ class Inferencer(algorithm.Visitor): node.keyword_loc) self.engine.process(diag) + def visit_withitem(self, node): + self.generic_visit(node) + if True: # none are supported yet + diag = diagnostic.Diagnostic("error", + "value of type {type} cannot act as a context manager", + {"type": types.TypePrinter().name(node.context_expr.type)}, + node.context_expr.loc) + self.engine.process(diag) + def visit_FunctionDefT(self, node): old_function, self.function = self.function, node old_in_loop, self.in_loop = self.in_loop, False