1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: check if the last or {} block expression is valid

These checks allows for:

a) `x := call() or { 'abc' }`
b) `x := call() or { panic('abc') }`
c) `x := call() or { exit(123) }`
d) `x := call() or { continue }`
e) `x := call() or { break }`
f) `x := call() or { return }`

... but produce errors for:

g) `x := call() or { println('an error') }` , etc.
This commit is contained in:
Daniel Däschle
2020-04-07 16:36:00 +02:00
committed by GitHub
parent 275b20a184
commit 0024ff848d
6 changed files with 72 additions and 11 deletions

View File

@@ -27,6 +27,7 @@ fn test_open_file() {
hello := 'hello world!'
os.open_file(filename, 'r+', 0o666) or {
assert err == 'No such file or directory'
os.File{}
}
mut file := os.open_file(filename, 'w+', 0o666) or {
panic(err)
@@ -212,7 +213,7 @@ fn test_is_writable_folder() {
tmp := os.temp_dir()
f := os.is_writable_folder(tmp) or {
eprintln('err: $err')
assert false
false
}
assert f
}