mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-07 14:24:43 +00:00
The error should only happen as a result of `_ = <expr>` not for an operand of a break expression that is discarded. Closes #13212
20 lines
321 B
Zig
20 lines
321 B
Zig
export fn foo() void {
|
|
var x: i32 = 1234;
|
|
x += 1;
|
|
_ = x;
|
|
}
|
|
export fn bar() void {
|
|
var b: u32 = 1;
|
|
_ = blk: {
|
|
const a = 1;
|
|
b = a;
|
|
break :blk a;
|
|
};
|
|
}
|
|
|
|
// error
|
|
// backend=stage2
|
|
// target=native
|
|
//
|
|
// :4:9: error: pointless discard of local variable
|
|
// :3:5: note: used here
|