; A task waiting in channel.recv observes cancellation on its cancelled edge; ; cancellation is a request, so the parent still joins it. ; expect: run ; grant: heap=mem.alloc:64 ; schedules: 20 ; result: 7 ; phase: 3 ; spec: docs/spec/04-concurrency-and-atomics.md module test.cancel_wait_recv air 0 lang 0.1 features [cancellation, capabilities, channels, effects, heap, ownership, resources, tasks] fn @main(%heap: cap) -> u8 effects [mem.alloc, task.spawn, task.wait] entry: %one = const.usize 1 channel.make u64, %one, %heap, ok -> @made, err -> @oom made(%tx: sender, %rx: receiver): %sc = task.scope.begin %t = task.spawn %sc, @waiter(%rx) task.cancel %t %r = task.join %t task.scope.end %sc channel.close_sender %tx ret %r oom(%e: alloc_error): trap fn @waiter(%rx: receiver) -> u8 effects [task.wait] entry: %rb = borrow.mut %rx channel.recv %rb, ok -> @got, closed -> @other, cancelled -> @cancelled got(%v: u64): borrow.end %rb br @close(%rx) other: borrow.end %rb br @close(%rx) close(%r: receiver): channel.close_receiver %r, ok -> @wrong, pending -> @pending pending(%r2: receiver): trap wrong: %z = const.u8 0 ret %z cancelled: borrow.end %rb channel.close_receiver %rx, ok -> @done, pending -> @pending done: %seven = const.u8 7 ret %seven