diff --git a/src/Sema.zig b/src/Sema.zig index 09268824c6dd2063f6a94d836416a36375c11e42..ba5ad7eb1566c69ee5377a8269d3ac512e073d31 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -3182,10 +3182,12 @@ fn ensureResultUsed( const zcu = pt.zcu; switch (ty.zigTypeTag(zcu)) { .void, .noreturn => return, - .error_set => return sema.fail(block, src, "error set is ignored", .{}), + .error_set => { + return sema.fail(block, src, "error set of type '{f}' is ignored", .{ty.fmt(pt)}); + }, .error_union => { const msg = msg: { - const msg = try sema.errMsg(src, "error union is ignored", .{}); + const msg = try sema.errMsg(src, "error union of type '{f}' is ignored", .{ty.fmt(pt)}); errdefer msg.destroy(sema.gpa); try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{}); break :msg msg; diff --git a/test/cases/compile_errors/ignored_deferred_function_call.zig b/test/cases/compile_errors/ignored_deferred_function_call.zig index 9980128f90de825fe1dc542d35357cea925db948..63a7f489f1b01fedbfdf6354a6a87671ddd7bb20 100644 --- a/test/cases/compile_errors/ignored_deferred_function_call.zig +++ b/test/cases/compile_errors/ignored_deferred_function_call.zig @@ -14,6 +14,6 @@ fn bar2() anyerror { // error // -// :2:14: error: error union is ignored +// :2:14: error: error union of type 'anyerror!i32' is ignored // :2:14: note: consider using 'try', 'catch', or 'if' -// :9:15: error: error set is ignored +// :9:15: error: error set of type 'anyerror' is ignored diff --git a/test/cases/compile_errors/ignored_expression_in_while_continuation.zig b/test/cases/compile_errors/ignored_expression_in_while_continuation.zig index 4d4441fa9bc9309e03ce43fbb5ac52a90a478f62..79553e16049c44e30f11a1eb587120843693e79a 100644 --- a/test/cases/compile_errors/ignored_expression_in_while_continuation.zig +++ b/test/cases/compile_errors/ignored_expression_in_while_continuation.zig @@ -24,10 +24,10 @@ fn bad2() anyerror { // error // -// :2:24: error: error union is ignored +// :2:24: error: error union of type 'anyerror!void' is ignored // :2:24: note: consider using 'try', 'catch', or 'if' -// :7:25: error: error union is ignored +// :7:25: error: error union of type 'anyerror!void' is ignored // :7:25: note: consider using 'try', 'catch', or 'if' -// :12:25: error: error union is ignored +// :12:25: error: error union of type 'anyerror!void' is ignored // :12:25: note: consider using 'try', 'catch', or 'if' -// :19:25: error: error set is ignored +// :19:25: error: error set of type 'anyerror' is ignored