about summary refs log tree commit diff
path: root/lang/zig/struct-anon.zig
blob: a666bd0894268008dddda6c8ff59f3384b4a2353 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const expect = @import("std").testing.expect;

test "fully anonymous struct" {
    dump(.{
        .int = @as(u32, 1234),
        .float = @as(f64, 12.34),
        .b = true,
        .s = "hi",
    });
}

fn dump(args: anytype) void {
    expect(args.int == 1234);
    expect(args.float == 12.34);
    expect(args.b);
    expect(args.s[0] == 'h');
    expect(args.s[1] == 'i');
    // Type is well infered, i.e. the following fail at comp time:
    // expect(args.a);
}