Commit 3d18c8c130

Veikka Tuominen <git@vexu.eu>
2022-07-26 12:30:20
Sema: resolve lazy values for compile log
Close #12204
1 parent d78532f
Changed files (2)
src
test
cases
compile_errors
src/Sema.zig
@@ -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,
     }
 }
test/cases/compile_errors/compile_log.zig
@@ -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