refactor(stdlib/S1.2): delete module_fns; dissolve legacy_direct_any [additive]

Delete module_fns as a separate function-author fact source. Its authors
already live in the module_decls raw facts, so lowerRetainedSameNameAuthors now
reads function authors straight out of module_decls (filtered to *FnDecl via
fnDeclOfRaw) — the same path → name → RawDeclRef store, fn-filtered. Remove
imports.ModuleFns / FnIndex / indexModuleFns / buildModuleFns / fnDeclOf, the
Compilation.module_fns field + its build + wiring, and ProgramIndex.module_fns.

Remove VisibilityMode.legacy_direct_any (the quarantined own-scope-plus-full-
import_graph mode): no production caller passed it, so the collectVisibleAuthors
and isVisible switch arms that handled it are dead and go too, collapsing
VisEdgeSet to the single flat-import walk. No semantic fallback is introduced;
import_graph stays the transitive-visibility source for findVisibleImpls.

Additive: the old maps stay active and lowering still consumes them — no
lowering consumer is cut over to the DeclTable (that is S3), and no resolution
behavior changes. Tests that drove the removed symbols are rerouted through
module_decls / the flat-edge walk.

Gate over the baseline-green corpus: zig build, zig build test (424/424),
bash tests/run_examples.sh (540 passed) — all exit 0; single-author output
byte-identical; multi-author 0722–0740 stdout/exit unchanged.
This commit is contained in:
agra
2026-06-09 11:36:04 +03:00
parent 8058be2538
commit cd7510067f
8 changed files with 98 additions and 180 deletions

View File

@@ -588,9 +588,9 @@ pub const GlobalInfo = struct { id: inst.GlobalId, ty: TypeId };
/// `*ProgramIndex` instead of `*Lowering`.
///
/// OWNS the declaration maps below. BORROWS `module_scopes` / `import_graph` /
/// `flat_import_graph` / `module_fns` (pointers into maps owned by the
/// compilation driver, `core.zig`) — those are read-only views and are never
/// freed here.
/// `flat_import_graph` / `module_decls` / `namespace_edges` / `decl_table`
/// (pointers into maps owned by the compilation driver, `core.zig`) — those are
/// read-only views and are never freed here.
///
/// Per-map allocators are preserved exactly as they were on `Lowering`:
/// `import_flags` / `fn_ast_map` / `global_names` use the lowering allocator
@@ -615,11 +615,6 @@ pub const ProgramIndex = struct {
/// `ns :: #import`). fix-0102c's bare-name disambiguation walks this to
/// decide which same-name authors a flat importer can reach. Borrowed view.
flat_import_graph: ?*std.StringHashMap(std.StringHashMap(void)) = null,
/// Module path → (function name → authoring `*const FnDecl`), mirroring
/// `module_scopes`. Retains every same-name author under its own path so
/// fix-0102c can resolve a flat call to the right module's function.
/// Borrowed view.
module_fns: ?*imports.ModuleFns = null,
/// Per-module scalar raw-decl index (`path → name → RawDeclRef`), built by
/// `imports.buildImportFacts`. The unified resolver's raw-fact store.
/// Borrowed view.
@@ -696,7 +691,7 @@ pub const ProgramIndex = struct {
pub fn deinit(self: *ProgramIndex) void {
// Owned maps only — module_scopes / import_graph / flat_import_graph /
// module_fns / module_decls / namespace_edges / decl_table are borrowed.
// module_decls / namespace_edges / decl_table are borrowed.
self.import_flags.deinit();
self.fn_ast_map.deinit();
self.qualified_fn_source.deinit();