diff --git a/vlib/v/checker/tests/mut_arg_different_muls_err.out b/vlib/v/checker/tests/mut_arg_different_muls_err.out new file mode 100644 index 00000000000000..917be05b15e989 --- /dev/null +++ b/vlib/v/checker/tests/mut_arg_different_muls_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/mut_arg_different_muls_err.vv:26:21: error: cannot use `&Window` as `&&Window` in argument 1 to `window_resized` + 24 | + 25 | fn on_event(mut w Window) { + 26 | window_resized(mut w) + | ^ + 27 | } + 28 | diff --git a/vlib/v/checker/tests/mut_arg_different_muls_err.vv b/vlib/v/checker/tests/mut_arg_different_muls_err.vv new file mode 100644 index 00000000000000..b4af7c30301be4 --- /dev/null +++ b/vlib/v/checker/tests/mut_arg_different_muls_err.vv @@ -0,0 +1,38 @@ +pub type WindowResizeFn = fn (window &Window, w int, h int) + +@[heap] +pub struct Window { + id string = '_window_' +pub mut: + resize_fn WindowResizeFn = unsafe { nil } +} + +@[params] +pub struct WindowParams { +pub: + on_resize WindowResizeFn = unsafe { nil } +} + +fn window_resized(mut w &Window) { + window_width, window_height := 200, 100 + + if w.resize_fn != WindowResizeFn(0) { + println('fn present ${window_width} ${window_height}') + w.resize_fn(w, window_width, window_height) + } +} + +fn on_event(mut w Window) { + window_resized(mut w) +} + +fn on_resize(window &Window, w int, h int) { + println(' ${w} ${h}') +} + +fn main() { + mut w := &Window{ + resize_fn: on_resize + } + on_event(mut w) +}