feat: full match expressions in bootstrap and selfhost

Lower match to if-else for literals, ranges, enum tags, and wildcards.
Fix bootstrap literal arms that always matched; port real arm AST/parser
and Lcx_LowerMatch to selfhost with last-expression return. Expand
pattern_matching example and add parse/use-after-move/double-mut golden
diagnostics. Selfhost-loop remains binary-identical.
This commit is contained in:
2026-07-16 16:19:43 +03:00
parent 2cbbccc508
commit f619316470
18 changed files with 786 additions and 110 deletions
+15 -1
View File
@@ -75,8 +75,19 @@ struct Pattern {
patLitKind: int, // for pkLiteral (token kind)
patLitText: String, // for pkLiteral (token text)
patRangeInclusive: bool, // for pkRange
patEnumPath: String, // for pkEnum (path joined)
patEnumPath: String, // for pkEnum: "Enum::Variant"
patStructName: String, // for pkStruct
patChild1: *Pattern, // range lo / nested
patChild2: *Pattern, // range hi / nested
}
// Match arm: pattern => body
struct MatchArm {
line: uint32,
column: uint32,
pattern: *Pattern,
body: *Expr,
next: *MatchArm,
}
// ---------------------------------------------------------------------------
@@ -165,6 +176,9 @@ struct Expr {
// Call arguments (linked list for multi-arg support)
callArgs: *ExprList,
callArgCount: int,
// Match arms (for ekMatch)
matchArms: *MatchArm,
matchArmCount: int,
}
// ---------------------------------------------------------------------------