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
@@ -0,0 +1,7 @@
[Package]
Name = "double_mut_borrow"
Version = "0.1.0"
Type = "bin"
[Build]
Output = "Bin"
@@ -0,0 +1,6 @@
error: type errors in project
error: mutable borrow conflict: arguments 1 and 2 both borrow '&mut x'
--> FILE:10:11
|
10 | TwoMut(&x, &x);
| ^
@@ -0,0 +1,12 @@
@[Checked]
func TwoMut(a: &mut int, b: &mut int) {
*a = 1;
*b = 2;
}
@[Checked]
func Main() -> int {
var x: int = 0;
TwoMut(&x, &x);
return 0;
}
+7
View File
@@ -0,0 +1,7 @@
[Package]
Name = "parse_error"
Version = "0.1.0"
Type = "bin"
[Build]
Output = "Bin"
@@ -0,0 +1,7 @@
error: parse errors in FILE
error: expected expression
--> FILE:2:13
|
2 | let x = ;
| ^
= help: the previous statement may be incomplete (missing value or ';')
@@ -0,0 +1,4 @@
func Main() -> int {
let x = ;
return 0;
}
+6 -3
View File
@@ -16,10 +16,13 @@ passed=0
failed=0
normalize() {
# Replace absolute path prefix with FILE, drop trailing blank lines
# Replace absolute paths with FILE (location markers and "in <path>" lines).
# Drop trailing blank lines.
sed -E \
-e "s|$DIR/[^:]+:|FILE:|g" \
-e "s|$ROOT/[^:]+:|FILE:|g" \
-e "s|$DIR/[^:[:space:]]+:|FILE:|g" \
-e "s|$ROOT/[^:[:space:]]+:|FILE:|g" \
-e "s|$DIR/[^:[:space:]]+|FILE|g" \
-e "s|$ROOT/[^:[:space:]]+|FILE|g" \
-e "s|//+|/|g" \
| sed -e :a -e '/^\n*$/{$d;N;ba' -e '}'
}
@@ -0,0 +1,7 @@
[Package]
Name = "use_after_move"
Version = "0.1.0"
Type = "bin"
[Build]
Output = "Bin"
@@ -0,0 +1,7 @@
error: type errors in project
error: use of moved value 'a'
--> FILE:10:25
|
10 | let c: own String = a;
| ^
= help: the value was moved; clone it or restructure ownership
@@ -0,0 +1,12 @@
@[Checked]
func Take(s: own String) -> own String {
return s;
}
@[Checked]
func Main() -> int {
let a: own String = "hello";
let b: own String = Take(a);
let c: own String = a;
return 0;
}