5 ms·
> https://github.com/ziglang/zig/issues/12040 https://github.com/ziglang/zig/issues/12040 This one is quite funny. Normally you'd use `if (a) ... else |b| ...`
by anonymoushn 4y ago
> https://github.com/ziglang/zig/issues/12040 https://github.com/ziglang/zig/issues/12040
This one is quite funny. Normally you'd use `if (a) ... else |b| ...` if the type of `a` was an error union, and you'd get the `if` branch if it was not an error and the `else` branch if it was an error. So I suspect that there's a coercion from bool to some error union here. Error unions with lazily computed error sets are allowed, and (as a result of this or of other choices about the ergonomics of conditionally-compiled code that would be made of #typedefs in C) error unions with empty error sets are allowed. Wow.