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

checker: fix struct field fntype value call (#19067)

This commit is contained in:
yuyi 2023-08-06 18:18:48 +08:00 committed by GitHub
parent 7ca23f6316
commit c3f7fe39ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -1779,7 +1779,7 @@ fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type {
// cannot hide interface expected type to make possible to pass its interface type automatically
earg_types << if targ.idx() != param.typ.idx() { param.typ } else { targ }
} else {
earg_types << targ
earg_types << param.typ
}
param_share := param.typ.share()
if param_share == .shared_t

View File

@ -0,0 +1,18 @@
struct Foo {
f fn (Foo) int = dummy
}
fn dummy(s Foo) int {
return 22
}
fn (mut s Foo) fun() int {
return s.f(s)
}
fn test_struct_field_fn_call() {
mut s := Foo{}
ret := s.fun()
println(ret)
assert ret == 22
}