Sema: fix type check in zirIntToPtr

Simple fix: don't assume a ptr type before it has been checked.

Closes #13567
This commit is contained in:
Veikka Tuominen 2022-11-17 12:09:53 +02:00
parent 7b131a7cd4
commit bc76873827
2 changed files with 10 additions and 1 deletions

View File

@ -18778,8 +18778,8 @@ fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
const type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
const ptr_ty = try sema.resolveType(block, src, extra.lhs);
const elem_ty = ptr_ty.elemType2();
try sema.checkPtrType(block, type_src, ptr_ty);
const elem_ty = ptr_ty.elemType2();
const target = sema.mod.getTarget();
const ptr_align = try ptr_ty.ptrAlignmentAdvanced(target, sema);

View File

@ -0,0 +1,9 @@
pub export fn entry() void {
_ = @intToPtr(i32, 10);
}
// error
// backend=stage2
// target=native
//
// :2:19: error: expected pointer type, found 'i32'