feat: support fallible results and scoped cleanup

This commit is contained in:
2026-10-26 12:37:15 +01:00
parent cd64afbb40
commit 9058135326
15 changed files with 1732 additions and 76 deletions
+16
View File
@@ -99,6 +99,14 @@ Code :: enum {
sentinel_mismatch
overlapping_memory_copy
unsupported_foreign_call
invalid_fallible_type
invalid_sum_type
invalid_fallible_operand
try_outside_fallible
incompatible_propagated_error
catch_type_mismatch
errdefer_outside_fallible
cleanup_control_flow
}
Diagnostic :: struct {
@@ -219,5 +227,13 @@ messages :: $enummap.init(Code, []u8, {
sentinel_mismatch = "slice sentinel does not match the expected value",
overlapping_memory_copy = "memory copy source and destination overlap",
unsupported_foreign_call = "foreign function calls are unsupported by the interpreter",
invalid_fallible_type = "fallible type requires a concrete success type and an enum, struct, or tagged union error channel",
invalid_sum_type = "sum composition requires compatible named enum, struct, or tagged union variants",
invalid_fallible_operand = "try and catch require a fallible operand",
try_outside_fallible = "try requires an enclosing fallible function",
incompatible_propagated_error = "propagated errors are not a subset of the function error channel",
catch_type_mismatch = "catch handler must produce the success type or terminate",
errdefer_outside_fallible = "errdefer requires an enclosing fallible function",
cleanup_control_flow = "cleanup cannot escape with return, break, continue, or try",
})