From e864c38cc38095a1496229803465fdd0d079f9c3 Mon Sep 17 00:00:00 2001 From: mlugg Date: Wed, 22 Jan 2025 04:16:16 +0000 Subject: Sema: fix crash when `inline` loop condition is not comptime-known --- src/Sema.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Sema.zig') diff --git a/src/Sema.zig b/src/Sema.zig index 978396e371..fb9b27a8cd 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -1824,7 +1824,14 @@ fn analyzeBodyInner( ); const uncasted_cond = try sema.resolveInst(extra.data.condition); const cond = try sema.coerce(block, Type.bool, uncasted_cond, cond_src); - const cond_val = try sema.resolveConstDefinedValue(block, cond_src, cond, null); + const cond_val = try sema.resolveConstDefinedValue( + block, + cond_src, + cond, + // If this block is comptime, it's more helpful to just give the outer message. + // This is particularly true if this came from a comptime `condbr` above. + if (block.isComptime()) null else .{ .simple = .inline_loop_operand }, + ); const inline_body = if (cond_val.toBool()) then_body else else_body; try sema.maybeErrorUnwrapCondbr(block, inline_body, extra.data.condition, cond_src); -- cgit v1.2.3