checker: do not deref non-pointer types in `fn_signature_using_aliases` (#12340)
parent
28cada3fd5
commit
51f5841b6e
|
@ -1150,7 +1150,9 @@ pub fn (t &Table) fn_signature_using_aliases(func &Fn, import_aliases map[string
|
||||||
param := func.params[i]
|
param := func.params[i]
|
||||||
mut typ := param.typ
|
mut typ := param.typ
|
||||||
if param.is_mut {
|
if param.is_mut {
|
||||||
typ = typ.deref()
|
if param.typ.is_ptr() {
|
||||||
|
typ = typ.deref()
|
||||||
|
}
|
||||||
sb.write_string('mut ')
|
sb.write_string('mut ')
|
||||||
}
|
}
|
||||||
if !opts.type_only {
|
if !opts.type_only {
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
vlib/v/checker/tests/interface_sameness_check_for_mutable_methods.vv:15:6: error: `St` incorrectly implements method `method` of interface `Interface`: expected return type `u32`
|
||||||
|
13 |
|
||||||
|
14 | fn bar() {
|
||||||
|
15 | foo(St{})
|
||||||
|
| ~~~~
|
||||||
|
16 | }
|
||||||
|
Details: main.Interface has `fn method(mut x main.Interface) u32`
|
||||||
|
main.St has `fn method(st main.St) int`
|
|
@ -0,0 +1,16 @@
|
||||||
|
interface Interface {
|
||||||
|
mut:
|
||||||
|
method() u32
|
||||||
|
}
|
||||||
|
|
||||||
|
struct St {}
|
||||||
|
|
||||||
|
fn (st St) method() int {
|
||||||
|
panic('')
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo(_ Interface) {}
|
||||||
|
|
||||||
|
fn bar() {
|
||||||
|
foo(St{})
|
||||||
|
}
|
Loading…
Reference in New Issue