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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user