diff --git a/lib/std/math/ln.zig b/lib/std/math/ln.zig index d2a5ae807ed4..bb352cd6e1bf 100644 --- a/lib/std/math/ln.zig +++ b/lib/std/math/ln.zig @@ -32,7 +32,7 @@ pub fn ln(x: anytype) @TypeOf(x) { return @as(comptime_int, math.floor(ln_64(@as(f64, x)))); }, .Int => |IntType| switch (IntType.signedness) { - .signed => return @compileError("ln not implemented for signed integers"), + .signed => @compileError("ln not implemented for signed integers"), .unsigned => return @as(T, math.floor(ln_64(@as(f64, x)))), }, else => @compileError("ln not implemented for " ++ @typeName(T)), diff --git a/lib/std/math/log.zig b/lib/std/math/log.zig index cab652c62087..6336726b39ce 100644 --- a/lib/std/math/log.zig +++ b/lib/std/math/log.zig @@ -29,7 +29,7 @@ pub fn log(comptime T: type, base: T, x: T) T { // TODO implement integer log without using float math .Int => |IntType| switch (IntType.signedness) { - .signed => return @compileError("log not implemented for signed integers"), + .signed => @compileError("log not implemented for signed integers"), .unsigned => return @floatToInt(T, math.floor(math.ln(@intToFloat(f64, x)) / math.ln(float_base))), }, diff --git a/lib/std/math/log10.zig b/lib/std/math/log10.zig index 19602fb4a256..84eced85f0c6 100644 --- a/lib/std/math/log10.zig +++ b/lib/std/math/log10.zig @@ -33,7 +33,7 @@ pub fn log10(x: anytype) @TypeOf(x) { return @as(comptime_int, math.floor(log10_64(@as(f64, x)))); }, .Int => |IntType| switch (IntType.signedness) { - .signed => return @compileError("log10 not implemented for signed integers"), + .signed => @compileError("log10 not implemented for signed integers"), .unsigned => return @floatToInt(T, math.floor(log10_64(@intToFloat(f64, x)))), }, else => @compileError("log10 not implemented for " ++ @typeName(T)), diff --git a/lib/std/math/log2.zig b/lib/std/math/log2.zig index fca941c49a0e..556c16f5cf95 100644 --- a/lib/std/math/log2.zig +++ b/lib/std/math/log2.zig @@ -39,7 +39,7 @@ pub fn log2(x: anytype) @TypeOf(x) { return result; }, .Int => |IntType| switch (IntType.signedness) { - .signed => return @compileError("log2 not implemented for signed integers"), + .signed => @compileError("log2 not implemented for signed integers"), .unsigned => return math.log2_int(T, x), }, else => @compileError("log2 not implemented for " ++ @typeName(T)), diff --git a/lib/std/math/sqrt.zig b/lib/std/math/sqrt.zig index d54063dcf62b..871cc58e4789 100644 --- a/lib/std/math/sqrt.zig +++ b/lib/std/math/sqrt.zig @@ -26,7 +26,7 @@ pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) { return @as(T, sqrt_int(u128, x)); }, .Int => |IntType| switch (IntType.signedness) { - .signed => return @compileError("sqrt not implemented for signed integers"), + .signed => @compileError("sqrt not implemented for signed integers"), .unsigned => return sqrt_int(T, x), }, else => @compileError("sqrt not implemented for " ++ @typeName(T)), diff --git a/src/AstGen.zig b/src/AstGen.zig index 7132dc07ef32..ae66cae662f6 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -5963,7 +5963,7 @@ fn ret(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref } else .{ .ty = try gz.addNodeExtended(.ret_type, node), }; - const operand = try expr(gz, scope, rl, operand_node); + const operand = try reachableExpr(gz, scope, rl, operand_node, node); switch (nodeMayEvalToError(tree, operand_node)) { .never => { diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 6240fae5875b..1a3e81e1765d 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -4999,6 +4999,15 @@ pub fn addCases(ctx: *TestContext) !void { "tmp.zig:2:5: note: control flow is diverted here", }); + ctx.objErrStage1("unreachable code - return return", + \\export fn a() i32 { + \\ return return 1; + \\} + , &[_][]const u8{ + "tmp.zig:2:5: error: unreachable code", + "tmp.zig:2:12: note: control flow is diverted here", + }); + ctx.objErrStage1("bad import", \\const bogus = @import("bogus-does-not-exist.zig",); , &[_][]const u8{