forked from M-Labs/artiq
1
0
Fork 0

compiler: Fix lifetime tracking for function call return values

GitHub: Fixes #1497.
This commit is contained in:
David Nadlinger 2020-07-28 00:33:28 +01:00
parent e4b16428f5
commit f8d1506922
2 changed files with 15 additions and 1 deletions

View File

@ -103,7 +103,7 @@ class RegionOf(algorithm.Visitor):
# The cache is borrow checked dynamically # The cache is borrow checked dynamically
return Global() return Global()
else: else:
self.visit_sometimes_allocating(node) return self.visit_sometimes_allocating(node)
# Value lives as long as the object/container, if it's mutable, # Value lives as long as the object/container, if it's mutable,
# or else forever # or else forever

View File

@ -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])