diff --git a/src/Sema.zig b/src/Sema.zig index faa8ab2abade89054e315434d2bc5182328488ba..13177ff77b35ff25802de36e4e98883008485d11 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -18069,6 +18069,12 @@ fn analyzeRet( try inlining.merges.results.append(sema.gpa, operand); try inlining.merges.br_list.append(sema.gpa, br_inst.toIndex().?); try inlining.merges.src_locs.append(sema.gpa, operand_src); + var body_block = block; + while (body_block.parent) |parent| body_block = parent; + if (body_block.runtime_cond == null and body_block.runtime_loop == null) { + body_block.runtime_cond = block.runtime_cond orelse block.runtime_loop; + body_block.runtime_loop = block.runtime_loop; + } } else { try sema.validateRuntimeValue(block, operand_src, operand); const ret_tag: Air.Inst.Tag = if (block.wantSafety()) .ret_safe else .ret; diff --git a/test/cases/compile_errors/inline_return.zig b/test/cases/compile_errors/inline_return.zig new file mode 100644 index 0000000000000000000000000000000000000000..e761e78e211d1d26a3040cd8afe30eb549caeb8e --- /dev/null +++ b/test/cases/compile_errors/inline_return.zig @@ -0,0 +1,16 @@ +inline fn select(cond: bool, a: anytype, b: anytype) @TypeOf(a, b) { + if (cond) { + return a; + } else { + return b; + } +} +export fn f(x: u32) u32 { + return select(x > 0, 2, 1); +} + +// error +// +// :9:18: error: value with comptime-only type 'comptime_int' depends on runtime control flow +// :2:9: note: runtime control flow here +// :9:18: note: called inline here