v2 / vlib / v / checker / tests / generic_interface_callback_arg_err.vv
26 lines · 23 sloc · 331 bytes · 593fdc5a9f00b13b76cc81a0f2d8fc71c13abf96
Raw
1// Regression test for issue #18320.
2struct CustomStruct {
3pub:
4 a int
5 b string
6}
7
8interface BaseInterface {
9 a int
10}
11
12fn callback[T](ctx BaseInterface, cb fn (T)) {
13 $if T is BaseInterface {
14 cb(ctx)
15 }
16}
17
18fn main() {
19 custom := CustomStruct{
20 a: 5
21 b: 'test'
22 }
23 callback(custom, fn (ctx CustomStruct) {
24 println(ctx)
25 })
26}
27