From b2e94de3585e0a1242e3a5d6c8fd331da9f2d4f5 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 13 Sep 2022 10:01:17 -0700 Subject: [PATCH] add compile error test for pointless discards --- test/cases/compile_errors/pointless discard.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 test/cases/compile_errors/pointless discard.zig diff --git a/test/cases/compile_errors/pointless discard.zig b/test/cases/compile_errors/pointless discard.zig new file mode 100644 index 0000000000..048bf8ac8d --- /dev/null +++ b/test/cases/compile_errors/pointless discard.zig @@ -0,0 +1,12 @@ +export fn foo() void { + var x: i32 = 1234; + x += 1; + _ = x; +} + +// error +// backend=stage2 +// target=native +// +// :4:9: error: pointless discard of local variable +// :3:5: note: used here