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,43 @@
# Expression and statement errors
# Missing variable name in let
fn test() -> int
let = 5
42
# Missing equals in assignment
fn test() -> int
let x 5
x
# Missing expression after operator
fn test() -> int
5 +
# Invalid array syntax (missing comma)
fn test() -> int
let arr = [1 2 3]
arr[0]
# Missing closing bracket in array
fn test() -> int
let arr = [1, 2, 3
arr[0]
# Invalid struct literal (missing field value)
fn test() -> int
struct Point
x: int
y: int
end
let p = Point { x: 5, y }
p.x
# Missing colon in struct literal
fn test() -> int
struct Point
x: int
y: int
end
let p = Point { x 5, y: 10 }
p.x