feat: support optional-capture conditional expressions

Reuse canonical matches for optional presence and exact by-value payload captures across checking, lowering and compile-time selection.

Snapshot the optional-match flag before selector construction: AST additions can reallocate storage and invalidate the borrowed tree until refresh.

Verified 268 bootstrap tests and 908 interpreter/native programs at -O0 and -O2, plus native allocator, LLVM and CLI checks.
This commit is contained in:
2026-10-29 22:20:48 +01:00
parent 46fc7f4c46
commit 9838b253ee
9 changed files with 293 additions and 27 deletions
+9
View File
@@ -528,8 +528,17 @@ recompiles_generated_records_without_borrowing_previous_ir test {
` [child, 2, "owned"],
` )
`}
`Captured proc(value ?i16) type {
` return if value |payload| struct { value i16 = payload } else bool
`}
`selected proc($value ?i16) i16 {
` return if $(value) |payload| payload else 7
`}
`main proc() i16 {
` parent Parent(40) :: {}
` captured Captured(40) :: {}
` absent Captured(null) :: false
` if (absent or captured.value != selected(40) or selected(null) != 7) return 0
` same Parent(40) :: parent
` child Child(40) :: same.child
` if (Child(40) == Child(41) or Parent(40) == Parent(41)) return 0