authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-07-26 13:30:20+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-07-26 16:40:24+03:00
log3d18c8c1300986541bc81d60e81fd702d4417629
tree95bb478a6cacbfc0e6b5ae5dc7525773d89a69a3
parentd78532f462b2d0b514bbd3c1c3ed36135dca766c

Sema: resolve lazy values for compile log

Close #12204

2 files changed, 10 insertions(+), 0 deletions(-)

src/Sema.zig+5
......@@ -4508,6 +4508,7 @@ fn zirCompileLog(
45084508 const arg = try sema.resolveInst(arg_ref);
45094509 const arg_ty = sema.typeOf(arg);
45104510 if (try sema.resolveMaybeUndefVal(block, src, arg)) |val| {
4511 try sema.resolveLazyValue(block, src, val);
45114512 try writer.print("@as({}, {})", .{
45124513 arg_ty.fmt(sema.mod), val.fmtValue(arg_ty, sema.mod),
45134514 });
......@@ -25440,6 +25441,10 @@ fn resolveLazyValue(
2544025441 const ty = val.castTag(.lazy_align).?.data;
2544125442 return sema.resolveTypeLayout(block, src, ty);
2544225443 },
25444 .lazy_size => {
25445 const ty = val.castTag(.lazy_size).?.data;
25446 return sema.resolveTypeLayout(block, src, ty);
25447 },
2544325448 else => return,
2544425449 }
2544525450}
test/cases/compile_errors/compile_log.zig+5
......@@ -6,9 +6,14 @@ fn bar(a: i32, b: []const u8) void {
66 @compileLog("a", a, "b", b);
77 @compileLog("end",);
88}
9export fn baz() void {
10 const S = struct { a: u32 };
11 @compileLog(@sizeOf(S));
12}
913
1014// error
1115// backend=llvm
1216// target=native
1317//
1418// :5:5: error: found compile log statement
19// :11:5: note: also here