v
v copied to clipboard
checker: check option fn returning error (fix #17423)
This PR check option fn returning error (fix #17423).
- Check option fn returning error.
- Add test.
- Modify all the related calls.
fn func() ?int {
return error('Some error')
}
fn main() {
mut a := ?int(5)
a = 1
a = none
a = func()
println(a)
}
PS D:\Test\v\tt1> v run .
tt1.v:2:2: warning: Option and Result types have been split, use `!Foo` to return errors
1 | fn func() ?int {
2 | return error('Some error')
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
3 | }
4 |
Option(error: Some error)