v2 / vlib / v / fmt / tests / comptime_field_selector_parentheses_keep.vv
23 lines · 20 sloc · 238 bytes · ef5be22f81005b2237311a79b6383138084b0c53
Raw
1struct Foo {
2mut:
3 test string
4 name string
5}
6
7fn (f Foo) print() {
8 println('test')
9}
10
11fn test[T]() {
12 mut t := T{}
13 t.name = '2'
14 $for f in T.fields {
15 $if f.typ is string {
16 println(t.$(f.name))
17 }
18 }
19}
20
21fn main() {
22 test[Foo]()
23}
24