aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/bugs/3046.zig
blob: 1122ab4fe9695bad98579ef1f7de3abfead3fdc8 (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
const std = @import("std");
const builtin = @import("builtin");
const expect = std.testing.expect;

const SomeStruct = struct {
    field: i32,
};

fn couldFail() anyerror!i32 {
    return 1;
}

var some_struct: SomeStruct = undefined;

test "fixed" {
    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
    if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
    if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;

    some_struct = SomeStruct{
        .field = couldFail() catch @as(i32, 0),
    };
    try expect(some_struct.field == 1);
}