Re:Why is Zig so Cool?
by metaltyphoon on Friday November 07, 2025 @10:23PM
(#45853845)
> I know that Zig doesn't allow attaching data to error for good reasons. If error data contains interior pointer then it causes memory safety problem
IMO this is not a good reason at all.
Changed to "valid reasons"
The problem of dangling pointers is not unique to error data.
If you wanted to have a parameter that gets filled in when there is an error, this exact issue will remain, it's completely unrelated to which language construct you use to capture errors and has more to do with having a good idea of how your errors are allocated, if they require allocation. I don't think the commenter in the GitHub issue thought this through at all, and probably didn't expect to have it be held up as some example of why you can't return tagged unions (because it's not an example of that, not even remotely).
https://github.com/ziglang/zig/issues/2647#issuecomment-2670...