stage2: allow @ptrToInt on anything that is a pointer at runtime

This in particular allows @ptrToInt on pointer-like optionals.
This commit is contained in:
Robin Voetter 2021-12-17 19:01:25 +01:00
parent d5621504b0
commit 16bddecff9

View File

@ -5381,7 +5381,7 @@ fn zirPtrToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
const inst_data = sema.code.instructions.items(.data)[inst].un_node;
const ptr = sema.resolveInst(inst_data.operand);
const ptr_ty = sema.typeOf(ptr);
if (ptr_ty.zigTypeTag() != .Pointer) {
if (!ptr_ty.isPtrAtRuntime()) {
const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ty});
}