With defer it's developer's responsibility to free resources in right order, when one depends on another. Maybe something like this in Zig would be better:
try std.fs.cwd().openFile(path, .{}) |file| : file.close()
{
// ... code ...
// file.close() is called at the end
}