Skip to content

Commit 3e084d8

Browse files
committed
Sema: only untyped undefined should coerce to all types
Closes #13958
1 parent 01dba1c commit 3e084d8

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/Sema.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pub 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'

0 commit comments

Comments
 (0)