suicmez/error_test/parser/pattern_errors.sui

44 lines
627 B
Text
Raw Permalink Normal View History

2025-12-15 21:18:25 +05:30
# Pattern matching errors
2025-12-15 21:26:39 +05:30
struct Point
x: int,
y: int,
end
2025-12-15 21:18:25 +05:30
2025-12-15 21:26:39 +05:30
enum Result
Ok(int)
Err(string)
end
2025-12-15 21:18:25 +05:30
# Invalid pattern in match
fn test() -> int
match 42
x => x
end
# Missing colon in struct pattern
2025-12-15 21:26:39 +05:30
fn test() -> int do
let p = Point { x: 5, y: 10 }
2025-12-15 21:18:25 +05:30
match p
Point { x 5, y: 10 } => 1
end
2025-12-15 21:26:39 +05:30
end
2025-12-15 21:18:25 +05:30
# Invalid enum pattern
2025-12-15 21:26:39 +05:30
fn test() -> int do
let r = Result::Ok(42)
2025-12-15 21:18:25 +05:30
match r
Result::Ok value => value
end
2025-12-15 21:26:39 +05:30
end
2025-12-15 21:18:25 +05:30
# 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
2025-12-15 21:26:39 +05:30
end