mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
Sema: improved source location for @panic operand coercion error
Similar to the previous commit, errors coercing the panic message to `[]const u8` now point at the operand to `@panic` rather than the actual builtin call.
This commit is contained in:
parent
e6cf3ce24c
commit
5a957a3281
@ -5671,10 +5671,14 @@ fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.I
|
||||
const src = inst_data.src();
|
||||
const msg_inst = try sema.resolveInst(inst_data.operand);
|
||||
|
||||
// `panicWithMsg` would perform this coercion for us, but we can get a better
|
||||
// source location if we do it here.
|
||||
const coerced_msg = try sema.coerce(block, Type.slice_const_u8, msg_inst, .{ .node_offset_builtin_call_arg0 = inst_data.src_node });
|
||||
|
||||
if (block.is_comptime) {
|
||||
return sema.fail(block, src, "encountered @panic at comptime", .{});
|
||||
}
|
||||
try sema.panicWithMsg(block, src, msg_inst, .@"@panic");
|
||||
try sema.panicWithMsg(block, src, coerced_msg, .@"@panic");
|
||||
return always_noreturn;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user