From 0fc645ab7084c1812d367583b37218359b21c02c Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 18 Jan 2018 17:15:36 -0500 Subject: emit a compile error for @panic called at compile time closes #706 --- src/ir.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index 4dd022c09f..4c107ce767 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -14499,6 +14499,11 @@ static TypeTableEntry *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructio if (type_is_invalid(msg->value.type)) return ira->codegen->builtin_types.entry_invalid; + if (ir_should_inline(ira->new_irb.exec, instruction->base.scope)) { + ir_add_error(ira, &instruction->base, buf_sprintf("encountered @panic at compile-time")); + return ira->codegen->builtin_types.entry_invalid; + } + TypeTableEntry *u8_ptr_type = get_pointer_to_type(ira->codegen, ira->codegen->builtin_types.entry_u8, true); TypeTableEntry *str_type = get_slice_type(ira->codegen, u8_ptr_type); IrInstruction *casted_msg = ir_implicit_cast(ira, msg, str_type); -- cgit v1.2.3