v2 / vlib / v / tests / comptime / comptime_on_method_arg_test.v
19 lines · 16 sloc · 216 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1struct Struct {
2 a int
3 b string
4}
5
6struct Abc {}
7
8fn (a Abc) generic[T](b T) {
9 $if T is $struct {
10 $for f in T.fields {
11 a.generic(b.$(f.name))
12 }
13 }
14}
15
16fn test_main() {
17 Abc{}.generic(Struct{})
18 assert true
19}
20