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(...@@ -3571,7 +3571,7 @@ fn ensureResultUsed(
3571 const msg = try sema.errMsg(block, src, "value of type '{}' ignored", .{ty.fmt(sema.mod)});3571 const msg = try sema.errMsg(block, src, "value of type '{}' ignored", .{ty.fmt(sema.mod)});
3572 errdefer msg.destroy(sema.gpa);3572 errdefer msg.destroy(sema.gpa);
3573 try sema.errNote(block, src, msg, "all non-void values must be used", .{});3573 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 '_'", .{});
3575 break :msg msg;3575 break :msg msg;
3576 };3576 };
3577 return sema.failWithOwnedErrorMsg(block, msg);3577 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 {...@@ -23,13 +23,13 @@ export fn f4() void {
23//23//
24// :5:30: error: value of type 'usize' ignored24// :5:30: error: value of type 'usize' ignored
25// :5:30: note: all non-void values must be used25// :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 '_'
27// :9:30: error: value of type 'usize' ignored27// :9:30: error: value of type 'usize' ignored
28// :9:30: note: all non-void values must be used28// :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 '_'
30// :13:31: error: value of type 'bool' ignored30// :13:31: error: value of type 'bool' ignored
31// :13:31: note: all non-void values must be used31// :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 '_'
33// :16:42: error: value of type 'usize' ignored33// :16:42: error: value of type 'usize' ignored
34// :16:42: note: all non-void values must be used34// :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 {...@@ -24,4 +24,4 @@ pub export fn entry() void {
24//24//
25// :18:43: error: value of type 'type' ignored25// :18:43: error: value of type 'type' ignored
26// :18:43: note: all non-void values must be used26// :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 {...@@ -11,4 +11,4 @@ fn bar() anyerror!i32 {
11//11//
12// :2:11: error: value of type 'i32' ignored12// :2:11: error: value of type 'i32' ignored
13// :2:11: note: all non-void values must be used13// :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 {...@@ -10,4 +10,4 @@ export fn foo() void {
10//10//
11// :3:9: error: value of type 'comptime_int' ignored11// :3:9: error: value of type 'comptime_int' ignored
12// :3:9: note: all non-void values must be used12// :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 {...@@ -14,7 +14,7 @@ fn bar() u8 {
14//14//
15// :2:5: error: value of type 'comptime_int' ignored15// :2:5: error: value of type 'comptime_int' ignored
16// :2:5: note: all non-void values must be used16// :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 '_'
18// :5:5: error: value of type 'u8' ignored18// :5:5: error: value of type 'u8' ignored
19// :5:5: note: all non-void values must be used19// :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 {...@@ -10,4 +10,4 @@ export fn foo() void {
10//10//
11// :3:9: error: value of type 'comptime_int' ignored11// :3:9: error: value of type 'comptime_int' ignored
12// :3:9: note: all non-void values must be used12// :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 {...@@ -11,4 +11,4 @@ fn bar() i32 {
11//11//
12// :2:8: error: value of type 'i32' ignored12// :2:8: error: value of type 'i32' ignored
13// :2:8: note: all non-void values must be used13// :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 {...@@ -8,4 +8,4 @@ export fn foo() void {
8//8//
9// :2:5: error: value of type 'comptime_int' ignored9// :2:5: error: value of type 'comptime_int' ignored
10// :2:5: note: all non-void values must be used10// :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 {...@@ -32,16 +32,16 @@ export fn f5() void {
32//32//
33// :5:25: error: value of type 'usize' ignored33// :5:25: error: value of type 'usize' ignored
34// :5:25: note: all non-void values must be used34// :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 '_'
36// :10:26: error: value of type 'usize' ignored36// :10:26: error: value of type 'usize' ignored
37// :10:26: note: all non-void values must be used37// :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 '_'
39// :15:26: error: value of type 'usize' ignored39// :15:26: error: value of type 'usize' ignored
40// :15:26: note: all non-void values must be used40// :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 '_'
42// :20:23: error: value of type 'bool' ignored42// :20:23: error: value of type 'bool' ignored
43// :20:23: note: all non-void values must be used43// :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 '_'
45// :25:34: error: value of type 'usize' ignored45// :25:34: error: value of type 'usize' ignored
46// :25:34: note: all non-void values must be used46// :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 '_'