Skip to content

Commit

Permalink
checker: fix struct field init with generic anon fn (add the test from
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Feb 23, 2024
1 parent 10c2f9e commit 0514de7
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions vlib/v/tests/struct_field_init_with_generic_anon_fn_test.v
@@ -0,0 +1,30 @@
pub struct Module {
}

pub struct Service {
callback fn () = unsafe { nil }
}

pub fn (mut self Module) do_anything[T]() {
}

pub fn (mut self Module) register[T]() {
_ := Service{
callback: fn [mut self] [T]() {
self.do_anything[T]()
}
}
}

struct Something {
}

struct SomethingDifferent {
}

fn test_struct_field_init_with_generic_anon_fn() {
mut mod := Module{}
mod.register[Something]()
mod.register[SomethingDifferent]()
assert true
}

0 comments on commit 0514de7

Please sign in to comment.