Files
zig/test/cases/compile_errors/ignored_comptime_value.zig
r00ster91 60830e36e3 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.
2024-05-14 01:13:48 +09:00

21 lines
460 B
Zig

export fn a() void {
comptime 1;
}
export fn b() void {
comptime bar();
}
fn bar() u8 {
return 2;
}
// error
// backend=stage2
// target=native
//
// :2:5: error: value of type 'comptime_int' ignored
// :2:5: note: all non-void values must be used
// :2:5: note: to discard the value, assign it to '_'
// :5:5: error: value of type 'u8' ignored
// :5:5: note: all non-void values must be used
// :5:5: note: to discard the value, assign it to '_'