| 1 | type TestSum = int | string |
| 2 | |
| 3 | struct Bar { |
| 4 | y int |
| 5 | } |
| 6 | |
| 7 | struct Foo { |
| 8 | mut: |
| 9 | a TestSum |
| 10 | b int |
| 11 | c string |
| 12 | d Bar |
| 13 | } |
| 14 | |
| 15 | fn main() { |
| 16 | $for f in Foo.fields { |
| 17 | $if f.typ is $sumtype { |
| 18 | dump(f.name) |
| 19 | $for f2 in f.variants { |
| 20 | $if f2.typ is $int { |
| 21 | assert f2.typ == typeof[int]().idx |
| 22 | dump('int') |
| 23 | } $else $if f2.typ is $string { |
| 24 | dump('string') |
| 25 | assert f2.typ == typeof[string]().idx |
| 26 | } |
| 27 | } |
| 28 | } $else $if f.typ is Bar { |
| 29 | $for f3 in f.fields { |
| 30 | assert f3.typ == typeof[int]().idx |
| 31 | dump(f3.name) |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |