v2 / vlib / v / checker / tests / closure_undefined_ident_err.vv
31 lines · 25 sloc · 391 bytes · 0c8ce3bcb9fd4a2e5bd5f991a5a07da976d780d7
Raw
1module main
2
3struct Custom {
4 name string
5}
6
7interface MyInterface {
8 some_function()
9}
10
11fn (c Custom) some_function() {
12 println('hello ${c.name} from ${@METHOD}')
13}
14
15fn main() {
16 a := Custom{'rabbit'}
17 x := a.some_function
18 x()
19 b := Custom{'horse'}
20 y := b.some_function
21 y()
22
23 c := Custom{'noname'}
24
25 $for method in MyInterface.methods {
26 z := fn [c] () {
27 c.$method()
28 }
29 z()
30 }
31}
32