aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/packed_struct_comparison.zig
blob: 0e02aee6837e44ea1cbcdd0b678b07e837fa054c (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
const x: Foo = .{};
const y: Foo = .{};

export fn a() void {
    _ = x > y;
}

export fn b() void {
    _ = x < y;
}

export fn c() void {
    _ = x >= y;
}
export fn d() void {
    _ = x <= y;
}

const Foo = packed struct {
    a: u4 = 10,
    b: u4 = 5,
};

// error
//
// :5:11: error: operator > not allowed for type 'tmp.Foo'
// :19:20: note: struct declared here
// :9:11: error: operator < not allowed for type 'tmp.Foo'
// :19:20: note: struct declared here
// :13:11: error: operator >= not allowed for type 'tmp.Foo'
// :19:20: note: struct declared here
// :16:11: error: operator <= not allowed for type 'tmp.Foo'
// :19:20: note: struct declared here