authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-01-05 13:43:06+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-01-05 14:26:53+02:00
log3e084d8de352927dad182f99aeb3f166b348c192
tree1476e9edc967d1475bd6f91d984cf6178c5b46ea
parent01dba1c054724b4957778932fb5cd0df14d214b3

Sema: only untyped undefined should coerce to all types

Closes #13958

2 files changed, 12 insertions(+), 1 deletions(-)

src/Sema.zig+1-1
......@@ -24477,7 +24477,7 @@ fn coerceExtra(
2447724477 return block.addBitCast(dest_ty, inst);
2447824478 }
2447924479
24480 const is_undef = if (maybe_inst_val) |val| val.isUndef() else false;
24480 const is_undef = inst_ty.zigTypeTag() == .Undefined;
2448124481
2448224482 switch (dest_ty.zigTypeTag()) {
2448324483 .Optional => optional: {
test/cases/compile_errors/only_untyped_undef_coerces_to_all_types.zig created+11
......@@ -0,0 +1,11 @@
1pub export fn entry() void {
2 const x: []u8 = undefined;
3 const y: f32 = x;
4 _ = y;
5}
6
7// error
8// backend=stage2
9// target=native
10//
11// :3:20: error: expected type 'f32', found '[]u8'