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
+32
View File
@@ -9648,6 +9648,38 @@ main func() void {
testing.expect_value(t, len(unwrap_if.body), 1)
}
@(test)
match_else_arm_is_not_captured_by_braceless_if :: proc(t: ^testing.T) {
text := `ready func() bool { return true }
main func() void {
value i32 = 0
match value {
0: if ready() _ = value
else: _ = value
}
}
`
source_file := source.Source{path="test.bro", text=text}
diagnostics := source.init_diagnostics(&source_file)
defer source.destroy_diagnostics(&diagnostics)
symbols := symbol.init_table()
defer symbol.destroy_table(&symbols)
stream := lexer.lex(&source_file, &diagnostics, &symbols)
defer delete(stream.items)
module := parser.parse(&stream, &source_file, &diagnostics)
defer ast.destroy_module(&module)
testing.expect_value(t, len(diagnostics.items), 0)
match_statement := module.statements[module.functions[1].body[1]]
testing.expect_value(t, len(match_statement.body), 2)
first_arm := module.statements[match_statement.body[0]]
first_if := module.statements[first_arm.body[0]]
testing.expect_value(t, first_if.kind, ast.Stmt_Kind.If)
testing.expect_value(t, len(first_if.else_body), 0)
else_arm := module.statements[match_statement.body[1]]
testing.expect_value(t, len(else_arm.patterns), 0)
}
@(test)
parser_diagnoses_braceless_if_without_parens_or_call :: proc(t: ^testing.T) {
text := `main func() void {