mirror of
https://github.com/ziglang/zig.git
synced 2026-02-04 21:53:38 +00:00
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:
parent
d5621504b0
commit
16bddecff9
@ -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});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user