verifier: preserve resource obligations across CFG handoff
This commit is contained in:
1 parent
0e98638bc6
commit
09fbf8a5bc
34 files changed
+1267
-67
No files matched your search
@@ -0,0 +1,41 @@
|
||||
; An integer switch hands the lent task to its targets; ending the borrow before the join on the default target is rejected.
|
||||
; expect: reject E4302
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §34
|
||||
module test.cfg_provenance_loan_switch
|
||||
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)
|
||||
%k = const.u8 7
|
||||
switch.u8 %k, 0 -> @zero_case(%t), default -> @other(%t)
|
||||
zero_case(%a: task<u8>):
|
||||
%va = task.join %a
|
||||
borrow.end %r
|
||||
task.scope.end %sc
|
||||
ret %va
|
||||
other(%b: task<u8>):
|
||||
borrow.end %r
|
||||
%vb = task.join %b
|
||||
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
|
||||
Reference in new issue
Block a user