Closed
Description
Reproduce this issue with:
bug.zig
:
const std = @import("std");
pub fn main() void {
const val : u8 = blk: {
if (false) break :blk 42;
break :blk 93;
};
std.debug.warn("val is {}\n", .{val});
const val2 = if (val == 42) @as(u8, 42) else @as(u8, 93);
std.debug.warn("val2 = {}\n", .{val2});
const tuple = .{if (val == 42) @as(u8, 42) else @as(u8, 93)};
std.debug.warn("tuple[0] is {}\n", .{tuple[0]});
// This assert fails!!!
//std.debug.assert(val == tuple[0]);
}
$ zig run bug.zig
val is 93
val2 is 93
tuple[0] is 42
This one boggles my mind. There are alot of places that can be changed that will make this error go away. I'm am perplexed by what combination of sorcery has caused this to happen and now I'm going to be very hesitant at how I use tuples (i.e. what I pass to print/format functions).
Metadata
Metadata
Assignees
Labels
No labels