Sema: resolve lazy values for compile log

Close #12204
This commit is contained in:
Veikka Tuominen 2022-07-26 13:30:20 +03:00
parent d78532f462
commit 3d18c8c130
2 changed files with 10 additions and 0 deletions

View File

@ -4508,6 +4508,7 @@ fn zirCompileLog(
const arg = try sema.resolveInst(arg_ref);
const arg_ty = sema.typeOf(arg);
if (try sema.resolveMaybeUndefVal(block, src, arg)) |val| {
try sema.resolveLazyValue(block, src, val);
try writer.print("@as({}, {})", .{
arg_ty.fmt(sema.mod), val.fmtValue(arg_ty, sema.mod),
});
@ -25440,6 +25441,10 @@ fn resolveLazyValue(
const ty = val.castTag(.lazy_align).?.data;
return sema.resolveTypeLayout(block, src, ty);
},
.lazy_size => {
const ty = val.castTag(.lazy_size).?.data;
return sema.resolveTypeLayout(block, src, ty);
},
else => return,
}
}

View File

@ -6,9 +6,14 @@ fn bar(a: i32, b: []const u8) void {
@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