zig/test/cases/compile_errors/pointless discard.zig
Veikka Tuominen 0a188190b3 AstGen: make pointless discard error more strict
The error should only happen as a result of `_ = <expr>` not
for an operand of a break expression that is discarded.

Closes #13212
2022-11-11 17:59:53 +02:00

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