Files
aji/tests/conformance/phase3/reject/cfg_provenance_loan_cbr.air
T

42 lines
866 B
LLVM

; Both cbr targets receive the lent task; ending the borrow before the join on one target is rejected.
; expect: reject E4302
; phase: 3
; spec: docs/spec/04-concurrency-and-atomics.md §34
module test.cfg_provenance_loan_cbr
air 0
lang 0.1
features [cancellation, effects, ownership, tasks]
fn @main() -> u8
effects [task.spawn, task.wait]
entry:
%x = local.alloc u8
local.zero %x
%r = borrow.ref %x
%sc = task.scope.begin
%t = task.spawn %sc, @rd(%r)
%c = const.bool true
cbr %c, @early(%t), @late(%t)
early(%a: task<u8>):
borrow.end %r
%va = task.join %a
task.scope.end %sc
ret %va
late(%b: task<u8>):
%vb = task.join %b
borrow.end %r
task.scope.end %sc
ret %vb
fn @rd(%p: ref<u8>) -> u8
effects []
entry:
%v = load %p
ret %v
fn @zero() -> u8
effects []
entry:
%z = const.u8 0
ret %z