mirror of
https://github.com/ziglang/zig.git
synced 2026-01-18 05:15:18 +00:00
Changed container and initializer syntax
* <container> { ... } -> <container> . { ... }
* <exrp> { ... } -> <expr> . { ...}
31 lines
420 B
Zig
31 lines
420 B
Zig
const assert = @import("std").debug.assert;
|
|
|
|
const A = struct.{
|
|
b: B,
|
|
};
|
|
|
|
const B = struct.{
|
|
c: C,
|
|
};
|
|
|
|
const C = struct.{
|
|
x: i32,
|
|
|
|
fn d(c: *const C) i32 {
|
|
return c.x;
|
|
}
|
|
};
|
|
|
|
fn foo(a: *const A) i32 {
|
|
return a.b.c.d();
|
|
}
|
|
|
|
test "incomplete struct param top level declaration" {
|
|
const a = A.{
|
|
.b = B.{
|
|
.c = C.{ .x = 13 },
|
|
},
|
|
};
|
|
assert(foo(a) == 13);
|
|
}
|