mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
AstGen: Pop error trace for continue
PR #12837 handled control flow for break and return, but I forgot about `continue`. This is effectively another break, so we just need another `.restore_err_ret_index` ZIR instruction. Resolves #13618.
This commit is contained in:
committed by
Veikka Tuominen
parent
283c92e362
commit
3fa226a80c
@@ -151,6 +151,57 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
||||
},
|
||||
});
|
||||
|
||||
cases.addCase(.{
|
||||
.name = "continue in while loop",
|
||||
.source =
|
||||
\\fn foo() !void {
|
||||
\\ return error.UhOh;
|
||||
\\}
|
||||
\\
|
||||
\\pub fn main() !void {
|
||||
\\ var i: usize = 0;
|
||||
\\ while (i < 3) : (i += 1) {
|
||||
\\ foo() catch continue;
|
||||
\\ }
|
||||
\\ return error.UnrelatedError;
|
||||
\\}
|
||||
,
|
||||
.Debug = .{
|
||||
.expect =
|
||||
\\error: UnrelatedError
|
||||
\\source.zig:10:5: [address] in main (test)
|
||||
\\ return error.UnrelatedError;
|
||||
\\ ^
|
||||
\\
|
||||
,
|
||||
},
|
||||
.ReleaseSafe = .{
|
||||
.exclude_os = .{
|
||||
.windows, // TODO
|
||||
.linux, // defeated by aggressive inlining
|
||||
},
|
||||
.expect =
|
||||
\\error: UnrelatedError
|
||||
\\source.zig:10:5: [address] in [function]
|
||||
\\ return error.UnrelatedError;
|
||||
\\ ^
|
||||
\\
|
||||
,
|
||||
},
|
||||
.ReleaseFast = .{
|
||||
.expect =
|
||||
\\error: UnrelatedError
|
||||
\\
|
||||
,
|
||||
},
|
||||
.ReleaseSmall = .{
|
||||
.expect =
|
||||
\\error: UnrelatedError
|
||||
\\
|
||||
,
|
||||
},
|
||||
});
|
||||
|
||||
cases.addCase(.{
|
||||
.name = "try return + handled catch/if-else",
|
||||
.source =
|
||||
|
||||
Reference in New Issue
Block a user