void-payloads, multi-pattern arms, and range patterns (match statements)

This commit is contained in:
2026-06-29 19:52:05 +02:00
parent 462632554c
commit c82f070d55
8 changed files with 499 additions and 106 deletions
+8 -3
View File
@@ -178,10 +178,14 @@ Stmt :: struct {
// `Defer` statements use `update` as the deferred statement (which may itself
// be a `Block`).
// `Match` statements use `expr` as the subject and `body` as the list of arm
// statements (each a `Match_Arm`). A `Match_Arm` uses `expr` as its pattern
// (`INVALID_EXPR` marks the `else` arm), `captures` for the optional payload
// capture (0 or 1 name, tagged-union variants only), and `body` as the arm body.
// statements (each a `Match_Arm`). A `Match_Arm` uses `patterns` as its pattern
// list (empty marks the `else` arm; more than one is a multi-pattern arm),
// `captures` for the optional payload capture (0 or 1 name, tagged-union variants
// only) with `pointer_capture` distinguishing `|@cap|` from `|cap|`, and `body`
// as the arm body.
captures: []symbol.Id,
// `Match_Arm` pattern list; empty ⇒ the `else` arm.
patterns: []Expr_Id,
guard: Expr_Id,
body: []Stmt_Id,
else_body: []Stmt_Id,
@@ -303,6 +307,7 @@ destroy_module :: proc(module: ^Module) {
}
for statement in module.statements {
delete(statement.captures, module.allocator)
delete(statement.patterns, module.allocator)
delete(statement.body, module.allocator)
delete(statement.else_body, module.allocator)
}