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:
parent
7ca23f6316
commit
c3f7fe39ec
@ -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
|
// 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 }
|
earg_types << if targ.idx() != param.typ.idx() { param.typ } else { targ }
|
||||||
} else {
|
} else {
|
||||||
earg_types << targ
|
earg_types << param.typ
|
||||||
}
|
}
|
||||||
param_share := param.typ.share()
|
param_share := param.typ.share()
|
||||||
if param_share == .shared_t
|
if param_share == .shared_t
|
||||||
|
18
vlib/v/tests/struct_field_fn_call_test.v
Normal file
18
vlib/v/tests/struct_field_fn_call_test.v
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user