Comptime var behavior within defer

To elaborate on this.
In addition to the natural end of the block, try introduces another exit to propagate the error from nop.
defer places its statement at both exits as is expected and because i is a comptime var both get evaluated at compile time, hence i being 2.

If the nop returns an empty error set, then zig knows there is no error to propagate so try doesn’t introduce another exit, hence i being 1.

7 Likes