Commit 16bddecff9

Robin Voetter <robin@voetter.nl>
2021-12-17 19:01:25
stage2: allow @ptrToInt on anything that is a pointer at runtime
This in particular allows @ptrToInt on pointer-like optionals.
1 parent d562150
Changed files (1)
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});
     }