mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-08 06:44:27 +00:00
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.
27 lines
674 B
Zig
27 lines
674 B
Zig
fn List(comptime Head: type, comptime Tail: type) type {
|
|
return union {
|
|
const Self = @This();
|
|
head: Head,
|
|
tail: Tail,
|
|
|
|
fn AppendReturnType(comptime item: anytype) type {
|
|
return List(Head, List(@TypeOf(item), void));
|
|
}
|
|
};
|
|
}
|
|
|
|
fn makeList(item: anytype) List(@TypeOf(item), void) {
|
|
return List(@TypeOf(item), void){ .head = item };
|
|
}
|
|
|
|
pub export fn entry() void {
|
|
@TypeOf(makeList(42)).AppendReturnType(64);
|
|
}
|
|
|
|
// error
|
|
// backend=llvm
|
|
// target=native
|
|
//
|
|
// :18:43: error: value of type 'type' ignored
|
|
// :18:43: note: all non-void values must be used
|
|
// :18:43: note: to discard the value, assign it to '_'
|