11
src/Sema.zig
11
src/Sema.zig
@@ -2869,7 +2869,16 @@ fn ensureResultUsed(
|
||||
};
|
||||
return sema.failWithOwnedErrorMsg(block, msg);
|
||||
},
|
||||
else => return sema.fail(block, src, "expression value is ignored", .{}),
|
||||
else => {
|
||||
const msg = msg: {
|
||||
const msg = try sema.errMsg(block, src, "value of type '{}' ignored", .{operand_ty.fmt(sema.mod)});
|
||||
errdefer msg.destroy(sema.gpa);
|
||||
try sema.errNote(block, src, msg, "all non-void values must be used", .{});
|
||||
try sema.errNote(block, src, msg, "this error can be suppressed by assigning the value to '_'", .{});
|
||||
break :msg msg;
|
||||
};
|
||||
return sema.failWithOwnedErrorMsg(block, msg);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,4 +7,6 @@ fn bar() anyerror!i32 { return 0; }
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:11: error: expression value is ignored
|
||||
// :2:11: error: value of type 'i32' ignored
|
||||
// :2:11: note: all non-void values must be used
|
||||
// :2:11: note: this error can be suppressed by assigning the value to '_'
|
||||
|
||||
@@ -6,4 +6,6 @@ export fn foo() void {
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:15: error: expression value is ignored
|
||||
// :2:15: error: value of type 'comptime_int' ignored
|
||||
// :2:15: note: all non-void values must be used
|
||||
// :2:15: note: this error can be suppressed by assigning the value to '_'
|
||||
|
||||
@@ -6,4 +6,6 @@ export fn foo() void {
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:5: error: expression value is ignored
|
||||
// :2:5: error: value of type 'comptime_int' ignored
|
||||
// :2:5: note: all non-void values must be used
|
||||
// :2:5: note: this error can be suppressed by assigning the value to '_'
|
||||
|
||||
@@ -6,4 +6,6 @@ export fn foo() void {
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:12: error: expression value is ignored
|
||||
// :2:12: error: value of type 'comptime_int' ignored
|
||||
// :2:12: note: all non-void values must be used
|
||||
// :2:12: note: this error can be suppressed by assigning the value to '_'
|
||||
|
||||
@@ -7,4 +7,6 @@ fn bar() i32 { return 0; }
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:8: error: expression value is ignored
|
||||
// :2:8: error: value of type 'i32' ignored
|
||||
// :2:8: note: all non-void values must be used
|
||||
// :2:8: note: this error can be suppressed by assigning the value to '_'
|
||||
|
||||
@@ -6,4 +6,6 @@ export fn foo() void {
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:5: error: expression value is ignored
|
||||
// :2:5: error: value of type 'comptime_int' ignored
|
||||
// :2:5: note: all non-void values must be used
|
||||
// :2:5: note: this error can be suppressed by assigning the value to '_'
|
||||
|
||||
Reference in New Issue
Block a user