| ... | @@ -189,3 +189,15 @@ test "errdefer used in function that doesn't return an error" { | ... | @@ -189,3 +189,15 @@ test "errdefer used in function that doesn't return an error" { |
| 189 | }; | 189 | }; |
| 190 | try expect(S.foo() == 5); | 190 | try expect(S.foo() == 5); |
| 191 | } | 191 | } |
| | 192 | |
| | 193 | // Originally reported at https://github.com/ziglang/zig/issues/10591 |
| | 194 | const defer_assign = switch (block: { |
| | 195 | var x = 0; |
| | 196 | defer x = 1; |
| | 197 | break :block x; |
| | 198 | }) { |
| | 199 | else => |i| i, |
| | 200 | }; |
| | 201 | comptime { |
| | 202 | if (defer_assign != 0) @compileError("defer_assign failed!"); |
| | 203 | } |