zig/test/cases/comptime_aggregate_print.zig
2024-03-26 17:06:14 +00:00

36 lines
727 B
Zig

const UnionContainer = union {
buf: [2]i32,
};
fn getUnionSlice() []i32 {
var c = UnionContainer{ .buf = .{ 1, 2 } };
return c.buf[0..2];
}
const StructContainer = struct {
buf: [2]i32,
};
fn getStructSlice() []i32 {
var c = StructContainer{ .buf = .{ 3, 4 } };
return c.buf[0..2];
}
comptime {
@compileLog(getUnionSlice());
@compileLog(getStructSlice());
}
pub fn main() !void {}
// TODO: the output here has been regressed by #19414.
// Restoring useful output here will require providing a Sema to TypedValue.print.
// error
//
// :20:5: error: found compile log statement
//
// Compile Log Output:
// @as([]i32, &(comptime alloc).buf[0..2])
// @as([]i32, &(comptime alloc).buf[0..2])