better parser errors
This commit is contained in:
parent
f83a8e3ca1
commit
dde1da8656
7 changed files with 93 additions and 113 deletions
|
|
@ -1,5 +1,14 @@
|
|||
# Pattern matching errors
|
||||
struct Point
|
||||
x: int,
|
||||
y: int,
|
||||
end
|
||||
|
||||
enum Result
|
||||
Ok(int)
|
||||
Err(string)
|
||||
end
|
||||
|
||||
# Invalid pattern in match
|
||||
fn test() -> int
|
||||
match 42
|
||||
|
|
@ -7,26 +16,20 @@ fn test() -> int
|
|||
end
|
||||
|
||||
# Missing colon in struct pattern
|
||||
fn test() -> int
|
||||
struct Point
|
||||
x: int
|
||||
y: int
|
||||
end
|
||||
let p = Point { x: 5, y: 10 }
|
||||
fn test() -> int do
|
||||
let p = Point { x: 5, y: 10 }
|
||||
match p
|
||||
Point { x 5, y: 10 } => 1
|
||||
end
|
||||
end
|
||||
|
||||
# Invalid enum pattern
|
||||
fn test() -> int
|
||||
enum Result
|
||||
Ok(int)
|
||||
Err(string)
|
||||
end
|
||||
let r = Result::Ok(42)
|
||||
fn test() -> int do
|
||||
let r = Result::Ok(42)
|
||||
match r
|
||||
Result::Ok value => value
|
||||
end
|
||||
end
|
||||
|
||||
# Missing pattern in match arm
|
||||
fn test() -> int
|
||||
|
|
@ -38,4 +41,4 @@ fn test() -> int
|
|||
fn test() -> int
|
||||
match 42
|
||||
x 0
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue