authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-26 10:44:40-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-26 10:44:40-07:00
logddf9ff79bd2eccadafcdf12b191c62c66b247b64
treeb1f5f2d6be676d0435024d464b3af7facdd617c3
parent77cb45f59f7b37c316af1762298d6032e2b130b5

Revert "thread: simplify and remove useless return in spawn (#8621)"

This reverts commit 77cb45f59f7b37c316af1762298d6032e2b130b5. Zig's error return traces will point to the return token if they happen to occur, so having multiple return statements makes those stack traces really helpful. This destroys debuggability.

1 files changed, 7 insertions(+), 5 deletions(-)

lib/std/Thread.zig+7-5
......@@ -360,13 +360,15 @@ pub fn spawn(comptime startFn: anytype, context: SpawnContextType(@TypeOf(startF
360360 MainFuncs.posixThreadMain,
361361 thread_obj.data.memory.ptr,
362362 );
363 return switch (err) {
364 0 => thread_obj,
365 os.EAGAIN => error.SystemResources,
363 switch (err) {
364 0 => return thread_obj,
365 os.EAGAIN => return error.SystemResources,
366366 os.EPERM => unreachable,
367367 os.EINVAL => unreachable,
368 else => os.unexpectedErrno(err),
369 };
368 else => return os.unexpectedErrno(err),
369 }
370
371 return thread_obj;
370372 }
371373
372374 var guard_end_offset: usize = undefined;