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

checker: vfmt overload_return_type.vv (#14557)

This commit is contained in:
yuyi 2022-05-30 18:49:13 +08:00 committed by GitHub
parent 78d1b7f4ef
commit 844ba2a177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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` vlib/v/checker/tests/overload_return_type.vv:20:8: error: cannot assign to `two`: expected `Point`, not `int`
12 | mut one := Point {x:1, y:2} 18 | y: 1
13 | mut two := Point {x:5, y:1} 19 | }
14 | two = one + two 20 | two = one + two
| ~~~~~~~~~ | ~~~~~~~~~
15 | } 21 | }

View File

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