fix peer type resolution with null
This commit is contained in:
parent
fd4c5f54f0
commit
b4e40cb59a
|
@ -10399,6 +10399,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
|
|||
|
||||
if (prev_type->id == ZigTypeIdNull) {
|
||||
prev_inst = cur_inst;
|
||||
any_are_null = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -482,3 +482,17 @@ test "@intCast to u0 and use the result" {
|
|||
S.doTheTest(0, 1, 0);
|
||||
comptime S.doTheTest(0, 1, 0);
|
||||
}
|
||||
|
||||
test "peer type resolution: unreachable, null, slice" {
|
||||
const S = struct {
|
||||
fn doTheTest(num: usize, word: []const u8) void {
|
||||
const result = switch (num) {
|
||||
0 => null,
|
||||
1 => word,
|
||||
else => unreachable,
|
||||
};
|
||||
expect(mem.eql(u8, result.?, "hi"));
|
||||
}
|
||||
};
|
||||
S.doTheTest(1, "hi");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user