better parser errors

This commit is contained in:
Masashi 2025-12-15 21:26:39 +05:30
commit dde1da8656
7 changed files with 93 additions and 113 deletions

View file

@ -1,47 +1,50 @@
# Bracket and parenthesis mismatch errors
# Missing closing parenthesis in function call
fn test() -> int
fn test() -> int do
let f = lambda(x) x
f(5
42
end
# Missing closing bracket in array access
fn test() -> int
fn test() -> int do
let arr = [1, 2, 3]
arr[0
42
end
struct Point
x: int,
y: int
end
# Missing closing brace in struct literal
fn test() -> int
struct Point
x: int
y: int
end
fn test() -> int do
let p = Point { x: 5, y: 10
p.x
end
# Missing closing parenthesis in tuple
fn test() -> int
fn test() -> int do
let t = (1, 2, 3
42
end
# Missing closing angle bracket in generic
fn test() -> int
fn test() -> int do
let v = Vec<int
42
end
# Extra closing parenthesis
fn test() -> int
fn test() -> int do
let x = (5))
x
# Mismatched brackets
fn test() -> int
let x = [1, 2, 3}
x[0]
end
# Missing opening parenthesis in expression
fn test() -> int
fn test() -> int do
let x = 5 + 3)
x
x
end