mirror of https://github.com/m-labs/artiq.git
transforms.inferencer: make sure parallel/sequential is lone manager.
This commit is contained in:
parent
3aa5acbaf3
commit
05fa80818a
|
@ -963,8 +963,7 @@ class Inferencer(algorithm.Visitor):
|
||||||
self.generic_visit(node)
|
self.generic_visit(node)
|
||||||
|
|
||||||
typ = node.context_expr.type
|
typ = node.context_expr.type
|
||||||
if not (types.is_builtin(typ, "parallel") or
|
if (types.is_builtin(typ, "parallel") or types.is_builtin(typ, "sequential") or
|
||||||
types.is_builtin(typ, "sequential") or
|
|
||||||
(isinstance(node.context_expr, asttyped.CallT) and
|
(isinstance(node.context_expr, asttyped.CallT) and
|
||||||
types.is_builtin(node.context_expr.func.type, "watchdog"))):
|
types.is_builtin(node.context_expr.func.type, "watchdog"))):
|
||||||
diag = diagnostic.Diagnostic("error",
|
diag = diagnostic.Diagnostic("error",
|
||||||
|
@ -977,6 +976,19 @@ class Inferencer(algorithm.Visitor):
|
||||||
self._unify(node.optional_vars.type, node.context_expr.type,
|
self._unify(node.optional_vars.type, node.context_expr.type,
|
||||||
node.optional_vars.loc, node.context_expr.loc)
|
node.optional_vars.loc, node.context_expr.loc)
|
||||||
|
|
||||||
|
def visit_With(self, node):
|
||||||
|
self.generic_visit(node)
|
||||||
|
|
||||||
|
for item_node in node.items:
|
||||||
|
typ = item_node.context_expr.type.find()
|
||||||
|
if (types.is_builtin(typ, "parallel") or types.is_builtin(typ, "sequential")) and \
|
||||||
|
len(node.items) != 1:
|
||||||
|
diag = diagnostic.Diagnostic("error",
|
||||||
|
"the '{kind}' context manager must be the only one in a 'with' statement",
|
||||||
|
{"kind": typ.name},
|
||||||
|
node.keyword_loc.join(node.colon_loc))
|
||||||
|
self.engine.process(diag)
|
||||||
|
|
||||||
def visit_ExceptHandlerT(self, node):
|
def visit_ExceptHandlerT(self, node):
|
||||||
self.generic_visit(node)
|
self.generic_visit(node)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
# RUN: %python -m artiq.compiler.testbench.inferencer +diag %s >%t
|
||||||
|
# RUN: OutputCheck %s --file-to-check=%t
|
||||||
|
|
||||||
|
# CHECK-L: ${LINE:+1}: error: the 'parallel' context manager must be the only one in a 'with' statement
|
||||||
|
with parallel, sequential:
|
||||||
|
pass
|
Loading…
Reference in New Issue