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

compiler: make optionals work with multi return

This commit is contained in:
joe-conigliaro
2020-02-02 12:53:23 +11:00
committed by GitHub
parent f0efb42a30
commit 554d1dd7c6
3 changed files with 91 additions and 52 deletions

View File

@ -144,3 +144,21 @@ fn test_opt_ptr() {
println('`$r2` should be none')
assert false
}
fn multi_return_opt(err bool) ?(string, string) {
if err {
return error('oops')
}
return 'hello', 'v'
}
fn test_multi_return_opt() {
a, b := multi_return_opt(false) or {
panic(err)
}
assert a == 'hello' && b == 'v'
_, _ := multi_return_opt(true) or {
assert err == 'oops'
return
}
}