zig

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

commit d0d84bf6ee389b74e4ea3c6da36a1c2bbef39fa1 (tree)
parent 6b8dc8dd9f3581300577a4d7f66ccebc803c4cf7
Author: Motiejus <motiejus@jakstys.lt>
Date:   Sun,  1 Mar 2026 17:27:35 +0000

stage0: create import ptr_nav during preamble comptime

Remove the s_in_main_analysis guard from the import decl_val handler's
ptr_type + ptr_nav creation.  The Zig compiler creates these entries
whenever imports are accessed in comptime context (via
analyzeNavRefInner), regardless of analysis phase.  Previously the C
sema only created them during main analysis, causing the first ~10
module-level IP entries to be in the wrong order.

This aligns the C sema's entries $124-$133 with the Zig compiler.
The remaining gap (62 entries, starting at Zig's memoized_call at
$134) requires porting memoized comptime call support.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

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

diff --git a/stage0/sema.c b/stage0/sema.c @@ -11559,8 +11559,10 @@ static bool analyzeBodyInner( resolved = s_file_root_type[fid]; // Create ptr_nav for the import nav, // matching Zig's analyzeNavRefInner. - if (s_in_main_analysis - && sema->file_idx != UINT32_MAX) { + // Created during both preamble and main analysis + // (the Zig compiler creates these whenever imports + // are accessed in comptime context). + if (sema->file_idx != UINT32_MAX) { uint32_t nav_idx2 = findNavInNamespace( s_file_namespace[sema->file_idx], decl_name); if (nav_idx2 != UINT32_MAX) {