| 1 | // vtest vflags: -cstrict -cc clang |
| 2 | |
| 3 | struct Object { |
| 4 | mut: |
| 5 | context bool |
| 6 | } |
| 7 | |
| 8 | fn (mut o Object) f(x int) int { |
| 9 | match x { |
| 10 | 0 { |
| 11 | old := o.context |
| 12 | defer(fn) { |
| 13 | o.context = old |
| 14 | } |
| 15 | o.context = true |
| 16 | } |
| 17 | 1 { |
| 18 | return 123 |
| 19 | } |
| 20 | else {} |
| 21 | } |
| 22 | |
| 23 | return 42 |
| 24 | } |
| 25 | |
| 26 | fn main() { |
| 27 | mut o := Object{} |
| 28 | println('${o.f(0)} ${o.context}') |
| 29 | println('${o.f(1)} ${o.context}') |
| 30 | println('${o.f(2)} ${o.context}') |
| 31 | } |
| 32 |