make record fields resolve type-factory calls before runtime validation

This commit is contained in:
2026-07-20 15:49:52 +02:00
parent ec36b6b861
commit 05aa7d084a
5 changed files with 76 additions and 12 deletions
+25 -1
View File
@@ -1189,7 +1189,12 @@ type_from_syntax :: proc(
}
return composed
case .Type_Call:
return resolve_type_factory_call(checker, ast.Expr_Id(item.count_expr), pkg, file)
expr_id := ast.Expr_Id(item.count_expr)
call_file := file
if expr_id != ast.INVALID_EXPR && int(expr_id) < len(checker.ast_module.exprs) {
call_file = ast.File_Id(checker.ast_module.exprs[expr_id].span.file)
}
return resolve_type_factory_call(checker, expr_id, pkg, call_file)
}
if changed {
return types.intern(store, item)
@@ -4072,6 +4077,25 @@ validate_meta_schema :: proc(checker: ^Checker) {
}
validate_type_nodes :: proc(checker: ^Checker) {
node_count := len(checker.module.types.nodes)
for index in 0..<node_count {
item := checker.module.types.nodes[index]
if item.kind != .Struct && item.kind != .Union {
continue
}
start := int(item.field_start)
end := start+int(item.field_count)
if start < 0 || end > len(checker.module.types.fields) {
continue
}
for slot in start..<end {
resolved := type_from_syntax(
checker, checker.module.types.fields[slot].type,
ast.Package_Id(item.pkg), ast.File_Id(item.file),
)
checker.module.types.fields[slot].type = resolved
}
}
validate_meta_schema(checker)
for item, index in checker.module.types.nodes {
id := types.DYNAMIC_START+types.Type(index)