Skip to content

Commit

Permalink
compiler: reject lambdas used as kernel functions (fixes #313).
Browse files Browse the repository at this point in the history
whitequark committed Mar 3, 2016
1 parent cfe72c7 commit 73bfbe5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions artiq/compiler/embedding.py
Original file line number Diff line number Diff line change
@@ -742,6 +742,16 @@ def _quote_function(self, function, loc):
else:
if hasattr(function, "artiq_embedded"):
if function.artiq_embedded.function is not None:
if function.__name__ == "<lambda>":
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.

0 comments on commit 73bfbe5

Please sign in to comment.