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>
This commit is contained in:
2026-03-01 17:27:35 +00:00
parent 6b8dc8dd9f
commit d0d84bf6ee

View File

@@ -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) {