forked from M-Labs/artiq
compiler: Fix lifetime tracking for function call return values
GitHub: Fixes #1497.
This commit is contained in:
parent
e4b16428f5
commit
f8d1506922
|
@ -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
|
||||||
|
|
|
@ -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])
|
Loading…
Reference in New Issue