fix: resolve module-alias-qualified type in reflection arg slot (issue 0147)

size_of(sel.Selection) and the other reflection builtins rejected a
module-alias-qualified type: in argument position it parses as a .field_access
expression (not the dotted .type_expr a declaration produces), and neither
isStaticTypeArg nor resolveTypeArg had a .field_access arm. Add both: a pure
namespace-decl scan in isStaticTypeArg, and resolution via namespaceAliasTarget
+ resolveNominalLeaf in the target module context in resolveTypeArg (mirroring
the value-position lowerFieldAccess path). No fabricated-stub fallback.

Regression: examples/0192-types-size-of-qualified-alias.sx
This commit is contained in:
agra
2026-06-21 09:33:46 +03:00
parent c21b683b08
commit 21d91e6718
7 changed files with 152 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
// Companion module for 0192 — exports `Selection`, a struct whose size is NOT 8
// bytes (so a wrong fallback like `.i64` would be detectable).
Selection :: struct { a: i32; b: i32; c: i32; } // 12 bytes

View File

@@ -0,0 +1,18 @@
// `size_of(alias.Type)` on a module-alias-qualified type must resolve the type,
// exactly as a declaration `: alias.Type` does. In argument position the
// qualified name parses as a field-access expression; resolveTypeArg now
// reconstructs the dotted name and resolves it through the alias map instead of
// returning `.unresolved`.
//
// Regression (issue 0147).
#import "modules/std.sx";
sel :: #import "0192-types-size-of-qualified-alias-mod.sx";
main :: () -> i32 {
// Qualified through the module alias, in a type-arg slot.
print("size={}\n", size_of(sel.Selection)); // 12
// Same name also resolves in a declaration (already worked).
s : sel.Selection = .{ a = 1, b = 2, c = 3 };
print("sum={}\n", s.a + s.b + s.c); // 6
return 0;
}

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,2 @@
size=12
sum=6