diff --git a/stage0/sema.c b/stage0/sema.c index 57cbb569df..16f8ae5086 100644 --- a/stage0/sema.c +++ b/stage0/sema.c @@ -5612,7 +5612,19 @@ static void zirFunc(Sema* sema, SemaBlock* block, uint32_t inst) { ftype_key.data.func_type.return_type = ret_ty; ftype_key.data.func_type.param_count = param_count; ftype_key.data.func_type.cc = cc; - (void)ipIntern(sema->ip, ftype_key); + InternPoolIndex func_type_ip = ipIntern(sema->ip, ftype_key); + + // Create pointer-to-function type (*const fn(...) ...). + // Matches what the Zig compiler creates in ensureNavValUpToDate + // when taking the address of the function for @export. + InternPoolKey ptr_key; + memset(&ptr_key, 0, sizeof(ptr_key)); + ptr_key.tag = IP_KEY_PTR_TYPE; + ptr_key.data.ptr_type.child = func_type_ip; + ptr_key.data.ptr_type.sentinel = IP_INDEX_NONE; + ptr_key.data.ptr_type.flags = PTR_FLAGS_SIZE_ONE | PTR_FLAGS_IS_CONST; + ptr_key.data.ptr_type.packed_offset = 0; + (void)ipIntern(sema->ip, ptr_key); } analyzeFuncBodyAndRecord(