summaryrefslogtreecommitdiff
path: root/test/cases/safety/resuming a non-suspended function which has been suspended and resumed.zig
blob: f8bf6d44c08f8551d6ce6311eea2af8ec6f679fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const std = @import("std");

pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
    _ = message;
    _ = stack_trace;
    std.process.exit(0);
}
fn foo() void {
    suspend {
        global_frame = @frame();
    }
    var f = async bar(@frame());
    _ = &f;
    std.process.exit(1);
}

fn bar(frame: anyframe) void {
    suspend {
        resume frame;
    }
    std.process.exit(1);
}

var global_frame: anyframe = undefined;
pub fn main() !void {
    _ = async foo();
    resume global_frame;
    std.process.exit(1);
}
// run
// backend=stage1
// target=native