diff --git a/artiq/compiler/validators/escape.py b/artiq/compiler/validators/escape.py index 000c3ee5b..5aae58e51 100644 --- a/artiq/compiler/validators/escape.py +++ b/artiq/compiler/validators/escape.py @@ -103,7 +103,7 @@ class RegionOf(algorithm.Visitor): # The cache is borrow checked dynamically return Global() else: - self.visit_sometimes_allocating(node) + return self.visit_sometimes_allocating(node) # Value lives as long as the object/container, if it's mutable, # or else forever diff --git a/artiq/test/lit/escape/error_call.py b/artiq/test/lit/escape/error_call.py new file mode 100644 index 000000000..8bbc7992f --- /dev/null +++ b/artiq/test/lit/escape/error_call.py @@ -0,0 +1,14 @@ +# RUN: %python -m artiq.compiler.testbench.embedding +diag %s 2>%t +# RUN: OutputCheck %s --file-to-check=%t + +from artiq.experiment import * + +@kernel +def leak(a): + return a + +@kernel +def entrypoint(): + # CHECK-L: ${LINE:+2}: error: cannot return an allocated value that does not live forever + # CHECK-L: ${LINE:+1}: note: ... to this point + return leak([1, 2, 3])