aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/non_scalar_sentinel.zig
blob: c2d8bced8d7bc14b3340b7ce989674250bcb952d (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const S = struct {};
const sentinel: S = .{};

comptime {
    _ = [0:sentinel]S;
}
comptime {
    _ = [:sentinel]S;
}
comptime {
    _ = [*:sentinel]S;
}

comptime {
    _ = @Type(.{ .array = .{ .child = S, .len = 0, .sentinel_ptr = &sentinel } });
}
comptime {
    _ = @Type(.{ .pointer = .{
        .size = .slice,
        .is_const = false,
        .is_volatile = false,
        .alignment = @alignOf(S),
        .address_space = .generic,
        .child = S,
        .is_allowzero = false,
        .sentinel_ptr = &sentinel,
    } });
}
comptime {
    _ = @Type(.{ .pointer = .{
        .size = .many,
        .is_const = false,
        .is_volatile = false,
        .alignment = @alignOf(S),
        .address_space = .generic,
        .child = S,
        .is_allowzero = false,
        .sentinel_ptr = &sentinel,
    } });
}

// error
//
// :5:12: error: non-scalar sentinel type 'tmp.S'
// :1:11: note: struct declared here
// :8:11: error: non-scalar sentinel type 'tmp.S'
// :1:11: note: struct declared here
// :11:12: error: non-scalar sentinel type 'tmp.S'
// :1:11: note: struct declared here
// :15:9: error: non-scalar sentinel type 'tmp.S'
// :1:11: note: struct declared here
// :18:9: error: non-scalar sentinel type 'tmp.S'
// :1:11: note: struct declared here
// :30:9: error: non-scalar sentinel type 'tmp.S'
// :1:11: note: struct declared here