1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/v/parser/tests/defer_propagate2.vv
2022-05-13 06:56:21 +03:00

24 lines
254 B
V

struct Abc {
mut:
x int = 123
}
fn (mut s Abc) close() ? {
println('> CLOSE 1 s.x: $s.x')
s.x = -1
println('> CLOSE 2 s.x: $s.x')
}
fn opt2() ?int {
mut s := Abc{}
dump(s.x)
defer {
s.close()?
}
return s.x
}
fn main() {
println(opt2()?)
}