From 73bfbe51dbd66f3c652746a2fd925c2decca15ab Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 3 Mar 2016 08:33:28 +0000 Subject: [PATCH] compiler: reject lambdas used as kernel functions (fixes #313). --- artiq/compiler/embedding.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/artiq/compiler/embedding.py b/artiq/compiler/embedding.py index 17155d767..1058c6a70 100644 --- a/artiq/compiler/embedding.py +++ b/artiq/compiler/embedding.py @@ -742,6 +742,16 @@ class Stitcher: else: if hasattr(function, "artiq_embedded"): if function.artiq_embedded.function is not None: + if function.__name__ == "": + note = diagnostic.Diagnostic("note", + "lambda created here", {}, + self._function_loc(function.artiq_embedded.function)) + diag = diagnostic.Diagnostic("fatal", + "lambdas cannot be used as kernel functions", {}, + loc, + notes=[note]) + self.engine.process(diag) + # Insert the typed AST for the new function and restart inference. # It doesn't really matter where we insert as long as it is before # the final call.