yield type check against yield target
This commit is contained in:
@@ -6268,6 +6268,40 @@ value_loop_label_does_not_shadow_own_yield_target :: proc(t: ^testing.T) {
|
||||
testing.expect_value(t, len(diagnostics.items), 0)
|
||||
}
|
||||
|
||||
@(test)
|
||||
labeled_block_supplies_value_if_branch_through_catch :: proc(t: ^testing.T) {
|
||||
text := `Failure :: enum { bad }
|
||||
ScanResult :: struct { end usize }
|
||||
scan func() ScanResult ! Failure { return .bad }
|
||||
main func() i32 {
|
||||
start usize = 3
|
||||
end :: if (true) done: {
|
||||
result :: scan() catch {
|
||||
yield :done start
|
||||
}
|
||||
yield :done result.end
|
||||
} else {
|
||||
yield start
|
||||
}
|
||||
if (end == start) return 0
|
||||
return 1
|
||||
}
|
||||
`
|
||||
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)
|
||||
ast_module := parser.parse(&stream, &source_file, &diagnostics)
|
||||
defer ast.destroy_module(&ast_module)
|
||||
hir_module := checker.check(&ast_module, &diagnostics, &symbols)
|
||||
defer hir.destroy_module(&hir_module)
|
||||
|
||||
testing.expect_value(t, len(diagnostics.items), 0)
|
||||
}
|
||||
|
||||
@(test)
|
||||
native_union_compiles_and_runs :: proc(t: ^testing.T) {
|
||||
output := "/tmp/brolang-test-unions"
|
||||
|
||||
Reference in New Issue
Block a user