zig/test/cases/compile_errors/compile_log.zig
Andrew Kelley 6664d2418d test-cases: add missing compile log output
The new testing harness is not bound by previous limitations; it can now
test compile log output as well.
2023-03-15 10:48:15 -07:00

29 lines
761 B
Zig

export fn foo() void {
comptime bar(12, "hi",);
}
fn bar(a: i32, b: []const u8) void {
@compileLog("begin",);
@compileLog("a", a, "b", b);
@compileLog("end",);
}
export fn baz() void {
const S = struct { a: u32 };
@compileLog(@sizeOf(S));
}
// error
// backend=llvm
// target=native
//
// :5:5: error: found compile log statement
// :11:5: note: also here
//
// Compile Log Output:
// @as(*const [5:0]u8, "begin")
// @as(*const [1:0]u8, "a"), @as(i32, 12), @as(*const [1:0]u8, "b"), @as([]const u8, "hi")
// @as(*const [3:0]u8, "end")
// @as(comptime_int, 4)
// @as(*const [5:0]u8, "begin")
// @as(*const [1:0]u8, "a"), @as(i32, [runtime value]), @as(*const [1:0]u8, "b"), @as([]const u8, [runtime value])
// @as(*const [3:0]u8, "end")