Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jan 10, 2025
1 parent c5ced97 commit 0766d49
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
7 changes: 7 additions & 0 deletions vlib/v/checker/tests/mut_arg_different_muls_err.out
Original file line number Diff line number Diff line change
@@ -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 |
38 changes: 38 additions & 0 deletions vlib/v/checker/tests/mut_arg_different_muls_err.vv
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 0766d49

Please sign in to comment.