| author | |
| committer | |
| log | 0fc645ab7084c1812d367583b37218359b21c02c |
| tree | b156e5bdc445b8b9b3b7763c358a195cf9438a1f |
| parent | 0b8f19fcba04cde35ca4831f37f8249d51da9432 |
closes #7062 files changed, 13 insertions(+), 0 deletions(-)
src/ir.cpp+5| ... | ... | @@ -14499,6 +14499,11 @@ static TypeTableEntry *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructio |
| 14499 | 14499 | if (type_is_invalid(msg->value.type)) |
| 14500 | 14500 | return ira->codegen->builtin_types.entry_invalid; |
| 14501 | 14501 | |
| 14502 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope)) { | |
| 14503 | ir_add_error(ira, &instruction->base, buf_sprintf("encountered @panic at compile-time")); | |
| 14504 | return ira->codegen->builtin_types.entry_invalid; | |
| 14505 | } | |
| 14506 | ||
| 14502 | 14507 | TypeTableEntry *u8_ptr_type = get_pointer_to_type(ira->codegen, ira->codegen->builtin_types.entry_u8, true); |
| 14503 | 14508 | TypeTableEntry *str_type = get_slice_type(ira->codegen, u8_ptr_type); |
| 14504 | 14509 | IrInstruction *casted_msg = ir_implicit_cast(ira, msg, str_type); |
test/compile_errors.zig+8| ... | ... | @@ -1,6 +1,14 @@ |
| 1 | 1 | const tests = @import("tests.zig"); |
| 2 | 2 | |
| 3 | 3 | pub fn addCases(cases: &tests.CompileErrorContext) { |
| 4 | cases.add("@panic called at compile time", | |
| 5 | \\export fn entry() { | |
| 6 | \\ comptime { | |
| 7 | \\ @panic("aoeu"); | |
| 8 | \\ } | |
| 9 | \\} | |
| 10 | , "error: encountered @panic at compile-time"); | |
| 11 | ||
| 4 | 12 | cases.add("wrong return type for main", |
| 5 | 13 | \\pub fn main() -> f32 { } |
| 6 | 14 | , "error: expected return type of main to be 'u8', 'noreturn', 'void', or '%void'"); |