authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2023-07-21 02:19:32+02:00
committergravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2024-05-14 01:13:48+09:00
log60830e36e38f49bc797ae731c9dd58d7231039bf
treeacfd10ac5e501668835d80992e8e11574e822f32
parente2ec54bb38eb7b157667f0a87c9eb929017c3710

Sema error: talk about discarding instead of suppressing

Maybe I'm just being pedantic here (most likely) but I don't like how we're just telling the user here how to "suppress this error" by "assigning the value to '_'". I think it's better if we use the word "discard" here which I think is the official terminology and also tells the user what it actually means to "assign the value to '_'". Also, using the value would also be a way to "suppress the error". It is just one of the two options: discard or use.

10 files changed, 18 insertions(+), 18 deletions(-)

src/Sema.zig+1-1
......@@ -3571,7 +3571,7 @@ fn ensureResultUsed(
35713571 const msg = try sema.errMsg(block, src, "value of type '{}' ignored", .{ty.fmt(sema.mod)});
35723572 errdefer msg.destroy(sema.gpa);
35733573 try sema.errNote(block, src, msg, "all non-void values must be used", .{});
3574 try sema.errNote(block, src, msg, "this error can be suppressed by assigning the value to '_'", .{});
3574 try sema.errNote(block, src, msg, "to discard the value, assign it to '_'", .{});
35753575 break :msg msg;
35763576 };
35773577 return sema.failWithOwnedErrorMsg(block, msg);
test/cases/compile_errors/for_loop_body_expression_ignored.zig+4-4
......@@ -23,13 +23,13 @@ export fn f4() void {
2323//
2424// :5:30: error: value of type 'usize' ignored
2525// :5:30: note: all non-void values must be used
26// :5:30: note: this error can be suppressed by assigning the value to '_'
26// :5:30: note: to discard the value, assign it to '_'
2727// :9:30: error: value of type 'usize' ignored
2828// :9:30: note: all non-void values must be used
29// :9:30: note: this error can be suppressed by assigning the value to '_'
29// :9:30: note: to discard the value, assign it to '_'
3030// :13:31: error: value of type 'bool' ignored
3131// :13:31: note: all non-void values must be used
32// :13:31: note: this error can be suppressed by assigning the value to '_'
32// :13:31: note: to discard the value, assign it to '_'
3333// :16:42: error: value of type 'usize' ignored
3434// :16:42: note: all non-void values must be used
35// :16:42: note: this error can be suppressed by assigning the value to '_'
35// :16:42: note: to discard the value, assign it to '_'
test/cases/compile_errors/generic_instantiation_failure.zig+1-1
......@@ -24,4 +24,4 @@ pub export fn entry() void {
2424//
2525// :18:43: error: value of type 'type' ignored
2626// :18:43: note: all non-void values must be used
27// :18:43: note: this error can be suppressed by assigning the value to '_'
27// :18:43: note: to discard the value, assign it to '_'
test/cases/compile_errors/ignored_assert-err-ok_return_value.zig+1-1
......@@ -11,4 +11,4 @@ fn bar() anyerror!i32 {
1111//
1212// :2:11: error: value of type 'i32' ignored
1313// :2:11: note: all non-void values must be used
14// :2:11: note: this error can be suppressed by assigning the value to '_'
14// :2:11: note: to discard the value, assign it to '_'
test/cases/compile_errors/ignored_comptime_statement_value.zig+1-1
......@@ -10,4 +10,4 @@ export fn foo() void {
1010//
1111// :3:9: error: value of type 'comptime_int' ignored
1212// :3:9: note: all non-void values must be used
13// :3:9: note: this error can be suppressed by assigning the value to '_'
13// :3:9: note: to discard the value, assign it to '_'
test/cases/compile_errors/ignored_comptime_value.zig+2-2
......@@ -14,7 +14,7 @@ fn bar() u8 {
1414//
1515// :2:5: error: value of type 'comptime_int' ignored
1616// :2:5: note: all non-void values must be used
17// :2:5: note: this error can be suppressed by assigning the value to '_'
17// :2:5: note: to discard the value, assign it to '_'
1818// :5:5: error: value of type 'u8' ignored
1919// :5:5: note: all non-void values must be used
20// :5:5: note: this error can be suppressed by assigning the value to '_'
20// :5:5: note: to discard the value, assign it to '_'
test/cases/compile_errors/ignored_deferred_statement_value.zig+1-1
......@@ -10,4 +10,4 @@ export fn foo() void {
1010//
1111// :3:9: error: value of type 'comptime_int' ignored
1212// :3:9: note: all non-void values must be used
13// :3:9: note: this error can be suppressed by assigning the value to '_'
13// :3:9: note: to discard the value, assign it to '_'
test/cases/compile_errors/ignored_return_value.zig+1-1
......@@ -11,4 +11,4 @@ fn bar() i32 {
1111//
1212// :2:8: error: value of type 'i32' ignored
1313// :2:8: note: all non-void values must be used
14// :2:8: note: this error can be suppressed by assigning the value to '_'
14// :2:8: note: to discard the value, assign it to '_'
test/cases/compile_errors/ignored_statement_value.zig+1-1
......@@ -8,4 +8,4 @@ export fn foo() void {
88//
99// :2:5: error: value of type 'comptime_int' ignored
1010// :2:5: note: all non-void values must be used
11// :2:5: note: this error can be suppressed by assigning the value to '_'
11// :2:5: note: to discard the value, assign it to '_'
test/cases/compile_errors/while_loop_body_expression_ignored.zig+5-5
......@@ -32,16 +32,16 @@ export fn f5() void {
3232//
3333// :5:25: error: value of type 'usize' ignored
3434// :5:25: note: all non-void values must be used
35// :5:25: note: this error can be suppressed by assigning the value to '_'
35// :5:25: note: to discard the value, assign it to '_'
3636// :10:26: error: value of type 'usize' ignored
3737// :10:26: note: all non-void values must be used
38// :10:26: note: this error can be suppressed by assigning the value to '_'
38// :10:26: note: to discard the value, assign it to '_'
3939// :15:26: error: value of type 'usize' ignored
4040// :15:26: note: all non-void values must be used
41// :15:26: note: this error can be suppressed by assigning the value to '_'
41// :15:26: note: to discard the value, assign it to '_'
4242// :20:23: error: value of type 'bool' ignored
4343// :20:23: note: all non-void values must be used
44// :20:23: note: this error can be suppressed by assigning the value to '_'
44// :20:23: note: to discard the value, assign it to '_'
4545// :25:34: error: value of type 'usize' ignored
4646// :25:34: note: all non-void values must be used
47// :25:34: note: this error can be suppressed by assigning the value to '_'
47// :25:34: note: to discard the value, assign it to '_'