v icon indicating copy to clipboard operation
v copied to clipboard

checker: check option fn returning error (fix #17423)

Open yuyi98 opened this issue 2 years ago • 0 comments

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)

yuyi98 avatar Feb 28 '23 14:02 yuyi98