fix(ir): resolve forward identifier type aliases in scanDecls (issue 0069)

scanDecls' `.identifier` alias branch registered `A :: B` into
ProgramIndex.type_alias_map only when `B` was already known (in
type_alias_map or the TypeTable). A forward target declared later
(`MyChain :: MyInt; MyInt :: s32;`) was never present during the single
forward scan, so the alias name went unregistered and the A2.4
unknown-type pass — which treats type_alias_map keys as declared types —
flagged its uses as `unknown type 'MyChain'`.

Add a fixpoint post-pass `resolveForwardIdentifierAliases` at the end of
scanDecls that re-resolves identifier-RHS aliases until no progress, after
every top-level name has been seen. A value const is never an `.identifier`
node, and an alias whose target is a value const still misses both lookups,
so issue 0068's value-const rejection is preserved.

Regression: examples/0132-types-forward-type-alias.sx (forward alias +
forward chain). Gate: zig build, zig build test, run_examples.sh -> 353/0.
This commit is contained in:
agra
2026-06-02 16:59:20 +03:00
parent 877014578e
commit 49a383df6d
6 changed files with 180 additions and 0 deletions

View File

@@ -0,0 +1 @@
7

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,3 @@
chain s32: 4
forward u8: 1
v + n: 10