mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: do not deref non-pointer types in fn_signature_using_aliases (#12340)
This commit is contained in:
@@ -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{})
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user