diff --git a/src/AstGen.zig b/src/AstGen.zig index 79e5ad963e9efb63edf914cb35de507b7841c951..1502b970178a9c6813605f7843fd4ad48c2b1d04 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -5127,7 +5127,7 @@ fn tryExpr( else => .none, }; // This could be a pointer or value depending on the `rl` parameter. - const operand = try expr(parent_gz, scope, operand_rl, operand_node); + const operand = try reachableExpr(parent_gz, scope, operand_rl, operand_node, node); const is_inline = parent_gz.force_comptime; const is_inline_bit = @as(u2, @boolToInt(is_inline)); const is_ptr_bit = @as(u2, @boolToInt(operand_rl == .ref)) << 1; diff --git a/test/cases/compile_errors/try_return.zig b/test/cases/compile_errors/try_return.zig new file mode 100644 index 0000000000000000000000000000000000000000..61e71e72b57c38a081818486971e9087771f7d99 --- /dev/null +++ b/test/cases/compile_errors/try_return.zig @@ -0,0 +1,11 @@ +pub fn foo() !void { + try return bar(); +} +pub fn bar() !void {} + +// error +// backend=stage2 +// target=native +// +// :2:5: error: unreachable code +// :2:9: note: control flow is diverted here