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:
1
examples/expected/0132-types-forward-type-alias.exit
Normal file
1
examples/expected/0132-types-forward-type-alias.exit
Normal file
@@ -0,0 +1 @@
|
||||
7
|
||||
1
examples/expected/0132-types-forward-type-alias.stderr
Normal file
1
examples/expected/0132-types-forward-type-alias.stderr
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
3
examples/expected/0132-types-forward-type-alias.stdout
Normal file
3
examples/expected/0132-types-forward-type-alias.stdout
Normal file
@@ -0,0 +1,3 @@
|
||||
chain s32: 4
|
||||
forward u8: 1
|
||||
v + n: 10
|
||||
Reference in New Issue
Block a user