zig/test/behavior
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
..
bugs Re-factor: Change AstGen.ResultLoc to be a struct 2022-10-21 11:22:46 -07:00
hasdecl
import
namespace_depends_on_compile_var
pub_enum
usingnamespace
align.zig stage1: Skip new tests that never passed in stage1 2022-10-13 12:53:20 -07:00
alignof.zig stage2 ARM: amend implementation of various AIR instructions 2022-09-09 19:17:17 +02:00
array.zig fix(text): hyphenation and other fixes 2022-10-05 21:19:10 +02:00
asm.zig stage2: fix some inline asm incompatibilities with stage1 2022-06-12 14:46:05 -07:00
async_fn.zig behavior tests: disable failing stage1 test 2022-03-23 14:06:07 -07:00
atomics.zig stage2: sparc64: Skip Sema-failing tests for now 2022-06-24 21:19:33 +07:00
await_struct.zig behavior tests: disable failing stage1 test 2022-03-23 14:06:07 -07:00
basic.zig fix(text): hyphenate "comptime" adjectives 2022-10-05 21:19:30 +02:00
bit_shifting.zig
bitcast.zig stage2: implement packedStuctToInt for more types 2022-10-18 14:05:48 +03:00
bitreverse.zig stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
bool.zig
byteswap.zig stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
byval_arg_var.zig stage2 ARM: implement basic intCast and error union wrapping 2022-06-25 21:16:51 +02:00
call.zig avoid exposing supportsTailCall in the standard library 2022-08-30 12:50:15 -07:00
cast.zig Sema: check pointer qualifiers before implicit cast 2022-09-20 00:50:13 +03:00
cast_int.zig organize behavior tests 2022-03-18 15:02:52 -07:00
comptime_memory.zig stage2 ARM: amend implementation of various AIR instructions 2022-09-09 19:17:17 +02:00
const_slice_child.zig stage2 ARM: implement ptr_elem_val 2022-09-09 19:17:18 +02:00
decltest.zig
defer.zig stage2: change how defers are stored in Zir 2022-09-12 01:52:44 -04:00
empty_union.zig Sema: allow empty enums and unions 2022-08-17 23:03:04 +03:00
enum.zig Sema: fix runtime int to enum with one possible value 2022-10-18 10:18:09 -07:00
error.zig stage2: Keep error return traces alive when storing to const 2022-10-21 12:40:29 -07:00
eval.zig Sema: allow runtime only instructions to be emitted in outside functions 2022-10-20 20:11:00 +03:00
export.zig stage2: implement exporting using field access (#13136) 2022-10-12 04:38:07 -04:00
export_self_referential_type_info.zig stage2: fix mem{set,cpy} for non comptime mutable pointers 2022-03-08 11:23:38 +02:00
field_parent_ptr.zig stage2 ARM: implement field_parent_ptr 2022-09-09 19:17:17 +02:00
floatop.zig Sema: error on ambiguous coercion of comptime float and ints 2022-08-17 14:09:09 -07:00
fn.zig Sema: fix implicit cast from extern fn to fn ptr 2022-08-22 11:16:36 +03:00
fn_delegation.zig stage2 AArch64: complete genTypedValue 2022-05-27 16:43:11 -04:00
fn_in_struct_in_comptime.zig
for.zig stage2 ARM: implement basic array_elem_val 2022-09-09 20:26:04 +02:00
generics.zig value: implement Value.eqlAdvanced on slices 2022-10-18 14:16:39 +02:00
hasdecl.zig
hasfield.zig Sema: make @hasField support tuples too 2022-03-11 12:59:20 -07:00
if.zig Sema: fix coerceResultPtr 2022-07-14 18:11:46 -07:00
import.zig
incomplete_struct_param_tld.zig aarch64: add airRetLoad for register mcv 2022-06-29 17:19:49 +02:00
inline_switch.zig Sema: inline switch capture needs to be set when switch operand is comptime known 2022-10-08 16:58:52 +03:00
int128.zig wasm: enable 128bit integer behavior tests 2022-05-18 07:43:33 +02:00
int_div.zig CBE: implement mod, divFloor, divTrunc 2022-03-19 21:01:36 -04:00
inttoptr.zig stage2 AArch64: add more slice support 2022-03-05 11:31:51 +01:00
ir_block_deps.zig x64: pass more behavior tests 2022-02-28 23:20:05 +01:00
math.zig fix(text): hyphenate "comptime" adjectives 2022-10-05 21:19:30 +02:00
maximum_minimum.zig all: rename @maximum to @max and @minimum to @min 2022-10-18 14:15:16 +03:00
member_func.zig
merge_error_sets.zig stage2 ARM: amend implementation of various AIR instructions 2022-09-09 19:17:17 +02:00
muladd.zig Re-enable mulAdd f128 tests on i386-linux 2022-10-13 12:53:30 -07:00
namespace_depends_on_compile_var.zig CBE: enable more tests that are currently passing 2022-03-17 11:39:56 -07:00
null.zig CBE: enable more tests that are currently passing 2022-03-17 11:39:56 -07:00
optional.zig LLVM: fix missing alignment on wrapping instructions 2022-08-25 16:15:48 -07:00
packed-struct.zig stage1: Skip new tests that never passed in stage1 2022-10-13 12:53:20 -07:00
packed_struct_explicit_backing_int.zig stage2: Implement explicit backing integers for packed structs 2022-08-10 19:54:45 +02:00
pointers.zig Sema: use correct value when @ptrCast operand is comptime known 2022-10-05 17:26:29 +03:00
popcount.zig stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
prefetch.zig
ptrcast.zig stage2 ARM: implement struct_field_val for registers 2022-09-09 19:17:18 +02:00
pub_enum.zig
ref_var_in_if_after_if_2nd_switch_prong.zig
reflection.zig stage2 ARM: implement basic intCast and error union wrapping 2022-06-25 21:16:51 +02:00
saturating_arithmetic.zig wasm: enable passing behavior tests 2022-06-19 17:27:56 +02:00
select.zig sema: coerce inputs to vectors in zirSelect 2022-03-25 19:14:11 +01:00
shuffle.zig mark some more behavior tests as passing 2022-05-25 00:12:56 -07:00
sizeof_and_typeof.zig Sema: fix using runtime instructions inside typeof in comptime only blocks 2022-10-20 20:11:12 +03:00
slice.zig codegen: add support for lowering .field_ptr on a slice 2022-10-12 12:40:59 +03:00
slice_sentinel_comptime.zig
src.zig Value: handle runtime_int in hashPtr 2022-10-20 20:11:12 +03:00
struct.zig fix(text): hyphenate "comptime" adjectives 2022-10-05 21:19:30 +02:00
struct_contains_null_ptr_itself.zig stage2 ARM: genSetStack for stack_argument_offset 2022-03-16 20:19:58 +01:00
struct_contains_slice_of_itself.zig stage2 ARM: implement basic intCast and error union wrapping 2022-06-25 21:16:51 +02:00
switch.zig stage2 ARM: implement struct_field_val for registers 2022-09-09 19:17:18 +02:00
switch_prong_err_enum.zig wasm: Enable passing behavior tests 2022-03-09 13:53:20 -07:00
switch_prong_implicit_cast.zig wasm: Enable passing behavior tests 2022-03-09 13:53:20 -07:00
this.zig stage2 ARM: amend implementation of various AIR instructions 2022-09-09 19:17:17 +02:00
translate_c_macros.h translate-c: convert tabs to \t in object-like macro string literals 2022-09-07 14:46:58 +03:00
translate_c_macros.zig translate-c: Escape non-ASCII characters that appear in macros 2022-09-10 01:50:17 +03:00
translate_c_macros_not_utf8.h translate-c: Escape non-ASCII characters that appear in macros 2022-09-10 01:50:17 +03:00
truncate.zig fix(text): hyphenate "comptime" adjectives 2022-10-05 21:19:30 +02:00
try.zig stage2 ARM: amend implementation of various AIR instructions 2022-09-09 19:17:17 +02:00
tuple.zig Sema: correct one possible value for tuples 2022-08-28 15:41:21 +03:00
type.zig Sema: check pointer qualifiers before implicit cast 2022-09-20 00:50:13 +03:00
type_info.zig Sema: check pointer qualifiers before implicit cast 2022-09-20 00:50:13 +03:00
typename.zig AstGen: reset anon_name_strategy for sub expressions 2022-09-24 16:30:37 +03:00
undefined.zig stage2: improve @typeName 2022-03-18 00:12:22 -07:00
underscore.zig stage2 ARM: fix recursive fibonacci 2022-05-22 21:02:32 +02:00
union.zig stage2 ARM: implement ptr_elem_val 2022-09-09 19:17:18 +02:00
union_with_members.zig organize behavior tests 2022-03-18 15:02:52 -07:00
usingnamespace.zig stage2 ARM: implement struct_field_val for registers 2022-09-09 19:17:18 +02:00
var_args.zig stage2 ARM: implement basic intCast and error union wrapping 2022-06-25 21:16:51 +02:00
vector.zig Re-enable Vector f16 tests on Windows 2022-10-13 12:53:20 -07:00
void.zig stage2: Reference to void constants 2022-08-26 00:00:22 -04:00
wasm.zig stage2: cleanups to wasm memory intrinsics 2022-03-03 18:31:55 -07:00
while.zig stage2 ARM: amend implementation of various AIR instructions 2022-09-09 19:17:17 +02:00
widening.zig stage2 ARM: implement basic intCast and error union wrapping 2022-06-25 21:16:51 +02:00
wrapping_arithmetic.zig