zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 16bddecff99eafb6c60d2c7a406d92d9c2d3c35a (tree)
parent d5621504b0e2160fa44991fc4180165584d72819
Author: Robin Voetter <robin@voetter.nl>
Date:   Fri, 17 Dec 2021 19:01:25 +0100

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

This in particular allows @ptrToInt on pointer-like optionals.

Diffstat:
Msrc/Sema.zig | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Sema.zig b/src/Sema.zig @@ -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}); }