better parser errors
This commit is contained in:
parent
872c8e356d
commit
f83a8e3ca1
13 changed files with 639 additions and 78 deletions
47
error_test/parser/bracket_errors.sui
Normal file
47
error_test/parser/bracket_errors.sui
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# Bracket and parenthesis mismatch errors
|
||||
|
||||
# Missing closing parenthesis in function call
|
||||
fn test() -> int
|
||||
let f = lambda(x) x
|
||||
f(5
|
||||
42
|
||||
|
||||
# Missing closing bracket in array access
|
||||
fn test() -> int
|
||||
let arr = [1, 2, 3]
|
||||
arr[0
|
||||
42
|
||||
|
||||
# Missing closing brace in struct literal
|
||||
fn test() -> int
|
||||
struct Point
|
||||
x: int
|
||||
y: int
|
||||
end
|
||||
let p = Point { x: 5, y: 10
|
||||
p.x
|
||||
|
||||
# Missing closing parenthesis in tuple
|
||||
fn test() -> int
|
||||
let t = (1, 2, 3
|
||||
42
|
||||
|
||||
# Missing closing angle bracket in generic
|
||||
fn test() -> int
|
||||
let v = Vec<int
|
||||
42
|
||||
|
||||
# Extra closing parenthesis
|
||||
fn test() -> int
|
||||
let x = (5))
|
||||
x
|
||||
|
||||
# Mismatched brackets
|
||||
fn test() -> int
|
||||
let x = [1, 2, 3}
|
||||
x[0]
|
||||
|
||||
# Missing opening parenthesis in expression
|
||||
fn test() -> int
|
||||
let x = 5 + 3)
|
||||
x
|
||||
Loading…
Add table
Add a link
Reference in a new issue