v4 / vlib / v / checker / tests / comptime_defer_err.vv
23 lines · 20 sloc · 258 bytes · 2e23f2a18b02ebfc805f2dc038f75acbdc72af3a
Raw
1module main
2
3struct Struct {
4 s string
5 i int
6}
7
8fn main() {
9 tst := Struct{
10 s: 'tst-s'
11 i: 42
12 }
13
14 $for field in Struct.fields {
15 $if field.typ is string {
16 defer {
17 if tst.$(field.name) == 'tst-s' {
18 println('found tst-s')
19 }
20 }
21 }
22 }
23}
24