better parser errors

This commit is contained in:
Masashi 2025-12-15 21:18:25 +05:30
commit f83a8e3ca1
13 changed files with 639 additions and 78 deletions

View file

@ -0,0 +1,41 @@
# Pattern matching errors
# Invalid pattern in match
fn test() -> int
match 42
x => x
end
# Missing colon in struct pattern
fn test() -> int
struct Point
x: int
y: int
end
let p = Point { x: 5, y: 10 }
match p
Point { x 5, y: 10 } => 1
end
# Invalid enum pattern
fn test() -> int
enum Result
Ok(int)
Err(string)
end
let r = Result::Ok(42)
match r
Result::Ok value => value
end
# Missing pattern in match arm
fn test() -> int
match 42
=> 0
end
# Missing fat arrow in match arm
fn test() -> int
match 42
x 0
end