better parser errors
This commit is contained in:
parent
872c8e356d
commit
f83a8e3ca1
13 changed files with 639 additions and 78 deletions
43
error_test/parser/expression_errors.sui
Normal file
43
error_test/parser/expression_errors.sui
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue