match statements

This commit is contained in:
2026-06-28 23:44:01 +02:00
parent 981ccb047a
commit 462632554c
12 changed files with 1057 additions and 6 deletions
+6
View File
@@ -134,6 +134,8 @@ Stmt_Kind :: enum u8 {
Block,
Defer,
Yield,
Match,
Match_Arm,
}
Assignment_Op :: enum u8 {
@@ -175,6 +177,10 @@ Stmt :: struct {
// `Block` statements (a bare `{ ... }` scope) use `body` as their statements.
// `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.
captures: []symbol.Id,
guard: Expr_Id,
body: []Stmt_Id,