zig/test
Cody Tapscott d060cbbec7 stage2: Keep error return traces alive when storing to const
This change extends the "lifetime" of the error return trace associated
with an error to continue throughout the block of a `const` variable
that it is assigned to.

This is necessary to support patterns like this one in test_runner.zig:
```zig
const result = foo();
if (result) |_| {
    // ... success logic
} else |err| {
    // `foo()` should be included in the error trace here
    return error.TestFailed;
}
```

To make this happen, the majority of the error return trace popping logic
needed to move into Sema, since `const x = foo();` cannot be examined
syntactically to determine whether it modifies the error return trace. We
also have to make sure not to delete pertinent block information before it
makes it to Sema, so that Sema can pop/restore around blocks correctly.

* Why do this only for `const` and not `var`? *

There is room to relax things for `var`, but only a little bit. We could
do the same thing we do for const and keep the error trace alive for the
remainder of the block where the *assignment* happens. Any wider scope
would violate the stack discipline for traces, so it's not viable.

In the end, I decided the most consistent behavior for the user is just
to kill all error return traces assigned to a mutable `var`.
2022-10-21 12:40:29 -07:00
..
behavior stage2: Keep error return traces alive when storing to const 2022-10-21 12:40:29 -07:00
c_abi make C ABI tests compile on arm, mips and riscv 2022-10-20 20:11:12 +03:00
cases delete failing recursive test 2022-10-20 20:11:12 +03:00
link test/link: remove redundant dependOn statements 2022-10-18 17:20:08 +02:00
src std lib API deprecations for the upcoming 0.9.0 release 2021-11-30 00:13:07 -07:00
stage2 Sema: allow runtime only instructions to be emitted in outside functions 2022-10-20 20:11:00 +03:00
standalone Module: fix early exit conditions during compilation 2022-10-15 14:18:35 -04:00
assemble_and_link.zig migrate from std.Target.current to @import("builtin").target 2021-10-04 23:48:55 -07:00
behavior.zig Sema: add missing calls to wip_captures.finalize 2022-10-20 20:11:12 +03:00
cases.zig re-enable nvptx tests 2022-10-15 10:39:19 -07:00
cli.zig Compilation: strip debug info from ReleaseSmall by default 2022-10-11 17:51:25 +02:00
compare_output.zig validate number literals in AstGen 2022-09-13 20:26:04 -04:00
compile_errors.zig fix(text): hyphenate "comptime" adjectives 2022-10-05 21:19:30 +02:00
gen_h.zig
link.zig Sema: implement linksection on functions 2022-10-18 14:02:10 +03:00
run_translated_c.zig translate-c: Fix #12263 2022-10-10 22:29:56 +02:00
stack_traces.zig stage2: Keep error return traces alive when storing to const 2022-10-21 12:40:29 -07:00
standalone.zig Module: fix early exit conditions during compilation 2022-10-15 14:18:35 -04:00
tests.zig Sema: implement linksection on functions 2022-10-18 14:02:10 +03:00
translate_c.zig Update translate-c tests 2022-10-11 00:43:53 +02:00