42 lines
899 B
LLVM
42 lines
899 B
LLVM
; The cancelled handle of task.join.cancel passed through an ordinary block argument keeps its loans.
|
|
; expect: reject E4302
|
|
; phase: 3
|
|
; spec: docs/spec/04-concurrency-and-atomics.md §34, §37
|
|
module test.cfg_provenance_cancel_arg
|
|
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)
|
|
task.join.cancel %t, ok -> @joined, cancelled -> @cancelled
|
|
joined(%v: u8):
|
|
task.scope.end %sc
|
|
borrow.end %r
|
|
ret %v
|
|
cancelled(%t1: task<u8>):
|
|
br @handle(%t1)
|
|
handle(%t2: task<u8>):
|
|
borrow.end %r
|
|
%v2 = task.join %t2
|
|
task.scope.end %sc
|
|
ret %v2
|
|
|
|
fn @rd(%p: ref<u8>) -> u8
|
|
effects []
|
|
entry:
|
|
%v = load %p
|
|
ret %v
|
|
|
|
fn @zero() -> u8
|
|
effects []
|
|
entry:
|
|
%z = const.u8 0
|
|
ret %z
|