aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/reify_struct.zig
blob: fcea61b46f4c97c9d0d43463383051ba7319a231 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
comptime {
    @Type(.{ .@"struct" = .{
        .layout = .auto,
        .fields = &.{.{
            .name = "foo",
            .type = u32,
            .default_value = null,
            .is_comptime = false,
            .alignment = 4,
        }},
        .decls = &.{},
        .is_tuple = true,
    } });
}
comptime {
    @Type(.{ .@"struct" = .{
        .layout = .auto,
        .fields = &.{.{
            .name = "3",
            .type = u32,
            .default_value = null,
            .is_comptime = false,
            .alignment = 4,
        }},
        .decls = &.{},
        .is_tuple = true,
    } });
}
comptime {
    @Type(.{ .@"struct" = .{
        .layout = .auto,
        .fields = &.{.{
            .name = "0",
            .type = u32,
            .default_value = null,
            .is_comptime = true,
            .alignment = 4,
        }},
        .decls = &.{},
        .is_tuple = true,
    } });
}
comptime {
    @Type(.{ .@"struct" = .{
        .layout = .@"extern",
        .fields = &.{.{
            .name = "0",
            .type = u32,
            .default_value = null,
            .is_comptime = true,
            .alignment = 4,
        }},
        .decls = &.{},
        .is_tuple = false,
    } });
}
comptime {
    @Type(.{ .@"struct" = .{
        .layout = .@"packed",
        .fields = &.{.{
            .name = "0",
            .type = u32,
            .default_value = null,
            .is_comptime = true,
            .alignment = 4,
        }},
        .decls = &.{},
        .is_tuple = false,
    } });
}

// error
// backend=stage2
// target=native
//
// :2:5: error: tuple cannot have non-numeric field 'foo'
// :16:5: error: tuple field name '3' does not match field index 0
// :30:5: error: comptime field without default initialization value
// :44:5: error: extern struct fields cannot be marked comptime
// :58:5: error: alignment in a packed struct field must be set to 0