zig/test/cases/incomplete_struct_param_tld.zig

31 lines
413 B
Zig
Raw Normal View History

2017-03-26 08:39:18 +01:00
const assert = @import("std").debug.assert;
const A = struct.{
2017-03-26 08:39:18 +01:00
b: B,
};
const B = struct.{
2017-03-26 08:39:18 +01:00
c: C,
};
const C = struct.{
2017-03-26 08:39:18 +01:00
x: i32,
fn d(c: *const C) i32 {
2017-03-26 08:39:18 +01:00
return c.x;
}
};
fn foo(a: A) i32 {
2017-03-26 08:39:18 +01:00
return a.b.c.d();
}
test "incomplete struct param top level declaration" {
const a = A.{
.b = B.{
.c = C.{ .x = 13 },
2017-03-26 08:39:18 +01:00
},
};
assert(foo(a) == 13);
}