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:
3
examples/0192-types-size-of-qualified-alias-mod.sx
Normal file
3
examples/0192-types-size-of-qualified-alias-mod.sx
Normal 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
|
||||
18
examples/0192-types-size-of-qualified-alias.sx
Normal file
18
examples/0192-types-size-of-qualified-alias.sx
Normal 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;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
size=12
|
||||
sum=6
|
||||
Reference in New Issue
Block a user