mirror of
https://github.com/m-labs/artiq.git
synced 2025-02-07 16:15:22 +08:00
compiler: Report non-kernel __enter__
/__exit__
methods
Signed-off-by: Jonathan Coates <jonathan.coates@oxionics.com>
This commit is contained in:
parent
0f0f030267
commit
c50f3a1c12
@ -1674,7 +1674,14 @@ class Inferencer(algorithm.Visitor):
|
||||
else:
|
||||
typ = typ.find()
|
||||
|
||||
if not (len(typ.args) == arity and len(typ.optargs) == 0):
|
||||
if not types.is_function(typ):
|
||||
diag = diagnostic.Diagnostic("error",
|
||||
"function '{attr}{attr_type}' must be a @kernel",
|
||||
{"attr": attr_name,
|
||||
"attr_type": printer.name(typ)},
|
||||
node.loc)
|
||||
self.engine.process(diag)
|
||||
elif not (len(typ.args) == arity and len(typ.optargs) == 0):
|
||||
diag = diagnostic.Diagnostic("error",
|
||||
"function '{attr}{attr_type}' must accept "
|
||||
"{arity} positional argument{s} and no optional arguments",
|
||||
|
20
artiq/test/lit/embedding/error_with_rpc.py
Normal file
20
artiq/test/lit/embedding/error_with_rpc.py
Normal file
@ -0,0 +1,20 @@
|
||||
# RUN: %python -m artiq.compiler.testbench.embedding +diag %s 2>%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
from artiq.experiment import kernel
|
||||
|
||||
class contextmgr:
|
||||
def __enter__(self):
|
||||
pass
|
||||
|
||||
@kernel
|
||||
def __exit__(self, n1, n2, n3):
|
||||
pass
|
||||
|
||||
c = contextmgr()
|
||||
|
||||
@kernel
|
||||
def entrypoint():
|
||||
# CHECK-L: ${LINE:+1}: error: function '__enter__[rpc2 #](...)->NoneType' must be a @kernel function
|
||||
with c:
|
||||
pass
|
Loading…
Reference in New Issue
Block a user