feat(imports): buildImportFacts raw-fact store (ModuleRawDeclIndex + NamespaceEdges) [stdlib A]
Phase A of the unified resolver (R5 locked design). Additive infrastructure
with NO behavior change — builds the import-side raw-fact store; nothing
consumes it yet.
- imports.zig: add RawDeclRef / RawAuthor / ModuleRawDeclIndex / ModuleDecls /
NamespaceTarget / NamespaceEdges, plus buildImportFacts (mirrors
buildModuleFns) producing a scalar per-module name→RawDeclRef index + the
namespace edges. Callable without IR lowering (LSP reuses it later).
- ast.zig: NamespaceDecl gains target_module_path, captured at resolution time
(the resolved_path otherwise lost on the node) so the namespace edge records
the alias target.
- imports.zig: same-module duplicate top-level name is now DIAGNOSED
("duplicate top-level declaration 'X'") where addOwnDecl would silently drop
the second author — replaces the discarded `_ =` at the three call sites.
- program_index.zig: borrowed views module_decls / namespace_edges (like
module_fns); deinit does not free them.
- core.zig: build the facts alongside buildModuleFns and point the borrowed
views at them.
- imports.test.zig: index unit tests (flat / directory / namespaced file /
namespaced directory / C-import namespace / same-name fn / same-name struct /
value-vs-type same spelling / raw const_decl) + the duplicate-name diagnostic
regression (fails pre-fix, passes after).
Gate (worktree): zig build, zig build test (incl. LSP corpus sweep), and
run_examples (471, byte-identical) all green; m3te ios-sim build exits 0.
This commit is contained in:
@@ -599,6 +599,14 @@ pub const ProgramIndex = struct {
|
||||
/// 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.
|
||||
module_decls: ?*imports.ModuleDecls = null,
|
||||
/// Namespace import edges (`importer → alias → NamespaceTarget`), built by
|
||||
/// `imports.buildImportFacts`, carrying each alias's resolved target path.
|
||||
/// Borrowed view.
|
||||
namespace_edges: ?*imports.NamespaceEdges = null,
|
||||
|
||||
// ── Declaration maps ──
|
||||
/// Function name → AST decl.
|
||||
@@ -640,7 +648,7 @@ pub const ProgramIndex = struct {
|
||||
|
||||
pub fn deinit(self: *ProgramIndex) void {
|
||||
// Owned maps only — module_scopes / import_graph / flat_import_graph /
|
||||
// module_fns are borrowed.
|
||||
// module_fns / module_decls / namespace_edges are borrowed.
|
||||
self.import_flags.deinit();
|
||||
self.fn_ast_map.deinit();
|
||||
self.qualified_fn_source.deinit();
|
||||
|
||||
Reference in New Issue
Block a user