| ... | ... | @@ -22349,40 +22349,16 @@ fn safetyPanic( |
| 22349 | 22349 | src: LazySrcLoc, |
| 22350 | 22350 | panic_id: PanicId, |
| 22351 | 22351 | ) CompileError!Zir.Inst.Index { |
| 22352 | | const msg = switch (panic_id) { |
| 22353 | | .unreach => "reached unreachable code", |
| 22354 | | .unwrap_null => "attempt to use null value", |
| 22355 | | .cast_to_null => "cast causes pointer to be null", |
| 22356 | | .incorrect_alignment => "incorrect alignment", |
| 22357 | | .invalid_error_code => "invalid error code", |
| 22358 | | .cast_truncated_data => "integer cast truncated bits", |
| 22359 | | .negative_to_unsigned => "attempt to cast negative value to unsigned integer", |
| 22360 | | .integer_overflow => "integer overflow", |
| 22361 | | .shl_overflow => "left shift overflowed bits", |
| 22362 | | .shr_overflow => "right shift overflowed bits", |
| 22363 | | .divide_by_zero => "division by zero", |
| 22364 | | .exact_division_remainder => "exact division produced remainder", |
| 22365 | | .inactive_union_field => "access of inactive union field", |
| 22366 | | .integer_part_out_of_bounds => "integer part of floating point value out of bounds", |
| 22367 | | .corrupt_switch => "switch on corrupt value", |
| 22368 | | .shift_rhs_too_big => "shift amount is greater than the type size", |
| 22369 | | .invalid_enum_value => "invalid enum value", |
| 22370 | | }; |
| 22371 | | |
| 22372 | | const msg_inst = msg_inst: { |
| 22373 | | // TODO instead of making a new decl for every panic in the entire compilation, |
| 22374 | | // introduce the concept of a reference-counted decl for these |
| 22375 | | var anon_decl = try block.startAnonDecl(); |
| 22376 | | defer anon_decl.deinit(); |
| 22377 | | break :msg_inst try sema.analyzeDeclRef(try anon_decl.finish( |
| 22378 | | try Type.Tag.array_u8.create(anon_decl.arena(), msg.len), |
| 22379 | | try Value.Tag.bytes.create(anon_decl.arena(), msg), |
| 22380 | | 0, // default alignment |
| 22381 | | )); |
| 22382 | | }; |
| 22352 | const panic_messages_ty = try sema.getBuiltinType("panic_messages"); |
| 22353 | const msg_decl_index = (try sema.namespaceLookup( |
| 22354 | block, |
| 22355 | src, |
| 22356 | panic_messages_ty.getNamespace().?, |
| 22357 | @tagName(panic_id), |
| 22358 | )).?; |
| 22383 | 22359 | |
| 22384 | | const casted_msg_inst = try sema.coerce(block, Type.initTag(.const_slice_u8), msg_inst, src); |
| 22385 | | return sema.panicWithMsg(block, src, casted_msg_inst); |
| 22360 | const msg_inst = try sema.analyzeDeclVal(block, src, msg_decl_index); |
| 22361 | return sema.panicWithMsg(block, src, msg_inst); |
| 22386 | 22362 | } |
| 22387 | 22363 | |
| 22388 | 22364 | fn emitBackwardBranch(sema: *Sema, block: *Block, src: LazySrcLoc) !void { |