feat(stdlib/S2.1a): resolver.zig owning pass + ResolvedProgram scaffold + 3 bare-name domains [additive]

Turn src/ir/resolver.zig from a raw author-collection facade into the OWNING
resolution pass: one exhaustive recursive AST walk (exhaustive switch over
ast.Node.Data with NO else arm, so a new node kind is a compile error here
rather than a silently unvisited subtree) populating a ResolvedProgram.

- ResolvedProgram: all 10 node-keyed side tables declared as
  AutoHashMap(*const ast.Node, ResolvedRef) + symbolic TemplateParamId/
  PackParamId registries. ResolvedRef is the S2.1 RAW form — collected author
  identity (AuthorSet, own ∪ flat), NO verdict (own-wins/ambiguity is S2.2).
- Populate the 3 bare-name domains (type / value-const / callable heads) via
  collectVisibleAuthors(.user_bare_flat); record $T / ..$Ts / $pack[i] as
  SYMBOLIC template/pack refs, never TypeIds. The 7 head/qualified/foreign
  domains stay declared-but-empty (S2.1b/c own them).
- Slot via Compilation.resolveProgram() after the program_index facts are
  wired and before lowerRoot; ResolvedProgram owned on Compilation, borrowed
  *ResolvedProgram lent to ProgramIndex (lowerToIR signature unchanged).
- Population proof unit test over real Phase A facts: the 3 tables are
  non-empty, keyed by node identity, and carry symbolic template/pack refs.

ADDITIVE / PARALLEL / UNCONSUMED: lowering still reads the OLD selectors, so
single-author output is byte-identical. Gate green: zig build; zig build test
(425/425, LSP smoke 574 files no crash); run_examples (540 passed, 0 failed,
byte-identical incl. FFI 12xx-14xx + 1615 ios-sim); resolver-target (18 xfail
unchanged).
This commit is contained in:
agra
2026-06-09 12:29:27 +03:00
parent b29037b257
commit b46ad8b7a7
4 changed files with 753 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ const types = @import("types.zig");
const inst = @import("inst.zig");
const errors = @import("../errors.zig");
const type_resolver = @import("type_resolver.zig");
const resolver = @import("resolver.zig");
const Node = ast.Node;
const TypeId = types.TypeId;
@@ -627,6 +628,11 @@ pub const ProgramIndex = struct {
/// in parallel with the import facts. Borrowed view; nothing in lowering
/// consumes it for selection yet (additive — S4 makes it the fact-store key).
decl_table: ?*imports.DeclTable = null,
/// The owning resolution pass's output (Fork C S2.1a), built by
/// `resolver.resolve` and owned by `Compilation`. Borrowed view; ADDITIVE /
/// PARALLEL / UNCONSUMED — nothing in lowering reads it yet (lowering still
/// uses the old selectors), so generated output is byte-identical.
resolved_program: ?*resolver.ResolvedProgram = null,
// ── Declaration maps ──
/// Function name → AST decl.