| author | |
| committer | |
| log | 9bc98f5911dd30ce4f0b62c6cc5eaaeb6d6b5e2d |
| tree | b68a94924f093adf6bd5136b290c64f912e82b95 |
| parent | 407061498ce1d23ec498cce234433d18668d46be |
3 files changed, 10 insertions(+), 8 deletions(-)
src/Sema.zig+4-2| ... | ... | @@ -3182,10 +3182,12 @@ fn ensureResultUsed( |
| 3182 | 3182 | const zcu = pt.zcu; |
| 3183 | 3183 | switch (ty.zigTypeTag(zcu)) { |
| 3184 | 3184 | .void, .noreturn => return, |
| 3185 | .error_set => return sema.fail(block, src, "error set is ignored", .{}), | |
| 3185 | .error_set => { | |
| 3186 | return sema.fail(block, src, "error set of type '{f}' is ignored", .{ty.fmt(pt)}); | |
| 3187 | }, | |
| 3186 | 3188 | .error_union => { |
| 3187 | 3189 | const msg = msg: { |
| 3188 | const msg = try sema.errMsg(src, "error union is ignored", .{}); | |
| 3190 | const msg = try sema.errMsg(src, "error union of type '{f}' is ignored", .{ty.fmt(pt)}); | |
| 3189 | 3191 | errdefer msg.destroy(sema.gpa); |
| 3190 | 3192 | try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{}); |
| 3191 | 3193 | break :msg msg; |
test/cases/compile_errors/ignored_deferred_function_call.zig+2-2| ... | ... | @@ -14,6 +14,6 @@ fn bar2() anyerror { |
| 14 | 14 | |
| 15 | 15 | // error |
| 16 | 16 | // |
| 17 | // :2:14: error: error union is ignored | |
| 17 | // :2:14: error: error union of type 'anyerror!i32' is ignored | |
| 18 | 18 | // :2:14: note: consider using 'try', 'catch', or 'if' |
| 19 | // :9:15: error: error set is ignored | |
| 19 | // :9:15: error: error set of type 'anyerror' is ignored |
test/cases/compile_errors/ignored_expression_in_while_continuation.zig+4-4| ... | ... | @@ -24,10 +24,10 @@ fn bad2() anyerror { |
| 24 | 24 | |
| 25 | 25 | // error |
| 26 | 26 | // |
| 27 | // :2:24: error: error union is ignored | |
| 27 | // :2:24: error: error union of type 'anyerror!void' is ignored | |
| 28 | 28 | // :2:24: note: consider using 'try', 'catch', or 'if' |
| 29 | // :7:25: error: error union is ignored | |
| 29 | // :7:25: error: error union of type 'anyerror!void' is ignored | |
| 30 | 30 | // :7:25: note: consider using 'try', 'catch', or 'if' |
| 31 | // :12:25: error: error union is ignored | |
| 31 | // :12:25: error: error union of type 'anyerror!void' is ignored | |
| 32 | 32 | // :12:25: note: consider using 'try', 'catch', or 'if' |
| 33 | // :19:25: error: error set is ignored | |
| 33 | // :19:25: error: error set of type 'anyerror' is ignored |