From 04512a3e13c05e5afbc59b89f35ac8422ddd71fc Mon Sep 17 00:00:00 2001 From: Tau Date: Sat, 13 Jul 2024 22:51:38 +0200 Subject: [PATCH] Fix #14238 While we can't cover every I/O function like this, lockStdErr covers std.debug.print and std.log.*, probably the most important places to leave a useful hint for newcomers to Zig. --- lib/std/Progress.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig index 190f66789756..a10fc1c6aa41 100644 --- a/lib/std/Progress.zig +++ b/lib/std/Progress.zig @@ -543,6 +543,8 @@ fn windowsApiUpdateThreadRun() void { /// /// The lock is recursive; the same thread may hold the lock multiple times. pub fn lockStdErr() void { + if (@inComptime()) + @compileError("I/O cannot be used from comptime. Consider using @compileError() or @compileLog()."); stderr_mutex.lock(); clearWrittenWithEscapeCodes() catch {}; }