checker: vfmt overload_return_type.vv (#14557)

yuyi 2022-05-30 18:49:13 +08:00 committed by Chewing_Bever
parent 6beac6f4b7
commit 76c92715e6
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
2 changed files with 19 additions and 13 deletions

View File

@ -1,6 +1,6 @@
vlib/v/checker/tests/overload_return_type.vv:14:11: error: cannot assign to `two`: expected `Point`, not `int`
12 | mut one := Point {x:1, y:2}
13 | mut two := Point {x:5, y:1}
14 | two = one + two
vlib/v/checker/tests/overload_return_type.vv:20:8: error: cannot assign to `two`: expected `Point`, not `int`
18 | y: 1
19 | }
20 | two = one + two
| ~~~~~~~~~
15 | }
21 | }

View File

@ -1,15 +1,21 @@
struct Point {
mut:
x int
y int
mut:
x int
y int
}
fn (a Point) +(b Point) int {
return a.x + b.x
fn (a Point) + (b Point) int {
return a.x + b.x
}
fn main() {
mut one := Point {x:1, y:2}
mut two := Point {x:5, y:1}
two = one + two
mut one := Point{
x: 1
y: 2
}
mut two := Point{
x: 5
y: 1
}
two = one + two
}