Skip to content

Commit

Permalink
Fix #14238
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tau-dev committed Jul 16, 2024
1 parent 24ebb83 commit 04512a3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/std/Progress.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
}
Expand Down

0 comments on commit 04512a3

Please sign in to comment.