diff options
| author | Jimmi Holst Christensen <jhc@dismail.de> | 2022-11-23 16:36:20 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-11-23 14:57:39 -0500 |
| commit | 258bee41bf58c9001ceaefc974fa594a26ac0fc5 (patch) | |
| tree | 52e858faeec541aca8323315d0a681b1cb5cab66 /lib/std/builtin.zig | |
| parent | 81d2135ca6ebd71b8c121a19957c8fbf7f87125b (diff) | |
| download | zig-258bee41bf58c9001ceaefc974fa594a26ac0fc5.tar.gz zig-258bee41bf58c9001ceaefc974fa594a26ac0fc5.zip | |
Get panic messages from builtin instead of creating anon decls
The TODO comment in safetyPanic mentions introducing the concept of
reference-counted decls. That sounds like Zig current semantics for
normal declarations. By placing the panic messages in builtin there is
no need for another concept in the compiler.
Diffstat (limited to 'lib/std/builtin.zig')
| -rw-r--r-- | lib/std/builtin.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 33604dfee7..d777bb8c9e 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -869,6 +869,26 @@ pub noinline fn returnError(st: *StackTrace) void { addErrRetTraceAddr(st, @returnAddress()); } +pub const panic_messages = struct { + pub const unreach = "reached unreachable code"; + pub const unwrap_null = "attempt to use null value"; + pub const cast_to_null = "cast causes pointer to be null"; + pub const incorrect_alignment = "incorrect alignment"; + pub const invalid_error_code = "invalid error code"; + pub const cast_truncated_data = "integer cast truncated bits"; + pub const negative_to_unsigned = "attempt to cast negative value to unsigned integer"; + pub const integer_overflow = "integer overflow"; + pub const shl_overflow = "left shift overflowed bits"; + pub const shr_overflow = "right shift overflowed bits"; + pub const divide_by_zero = "division by zero"; + pub const exact_division_remainder = "exact division produced remainder"; + pub const inactive_union_field = "access of inactive union field"; + pub const integer_part_out_of_bounds = "integer part of floating point value out of bounds"; + pub const corrupt_switch = "switch on corrupt value"; + pub const shift_rhs_too_big = "shift amount is greater than the type size"; + pub const invalid_enum_value = "invalid enum value"; +}; + pub inline fn addErrRetTraceAddr(st: *StackTrace, addr: usize) void { if (st.index < st.instruction_addresses.len) st.instruction_addresses[st.index] = addr; |
