zig

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

commit e83257bed5f286117a8cbaf4d2efe491e0bb2a1b (tree)
parent 64e2ca5959ab1e6995ecd93c793ca01e1fb01d93
Author: Motiejus <motiejus@jakstys.lt>
Date:   Thu, 26 Feb 2026 23:48:17 +0000

sema: remove spurious ptr_nav creation from type alias and comptime nav resolution

In the Zig compiler, ensureNavResolved only resolves a nav's value
(creating struct_type, enum_type, etc.) — it does NOT create ptr_nav.
The ptr_nav is created separately by analyzeNavRefInner when a nav
is explicitly accessed as a value.

The C sema's resolveZirTypeInst (decl_val path) and analyzeNavValC
both created ptr_nav entries that the Zig compiler doesn't create at
those points, causing IP ordering divergence. Remove these spurious
ptr_nav creations — callers that need ptr_nav (resolveNestedTypeDecl,
resolveBuiltinDeclTypes, etc.) already create it explicitly.

This fixes 5 extra ptr_nav entries for type aliases like ErrorSet and
moves the first IP divergence point from index 439 to 441 for
neghf2.zig.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Diffstat:
Mstage0/sema.c | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/stage0/sema.c b/stage0/sema.c @@ -3282,9 +3282,6 @@ static InternPoolIndex resolveZirTypeInst( if (result != IP_INDEX_NONE) { Nav* wnav = ipGetNav(nav); wnav->resolved_type = result; - InternPoolIndex pt - = internPtrConst(IP_INDEX_TYPE_TYPE); - (void)internNavPtr(pt, nav); } return result; } @@ -4372,11 +4369,14 @@ static InternPoolIndex analyzeNavValC(uint32_t nav_idx) { if (result_type == IP_INDEX_NONE) return IP_INDEX_NONE; - // Cache the resolved value and create ptr_nav. + // Cache the resolved value. + // Note: we do NOT create ptr_nav here. In the Zig compiler, + // ensureNavResolved only resolves the value; ptr_nav creation is + // handled separately by analyzeNavRefInner (called from analyzeNavVal). + // Callers that need ptr_nav (resolveNestedTypeDecl, etc.) create it + // explicitly. nav = ipGetNav(nav_idx); nav->resolved_type = result_ip; - InternPoolIndex ptr_type = internPtrConst(result_type); - (void)internNavPtr(ptr_type, nav_idx); return result_ip; }