aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2024-08-31 00:40:59 +0100
committermlugg <mlugg@mlugg.co.uk>2024-09-01 18:31:01 +0100
commit2b9af9e825fcbfd55f953e7c3bc80decb52a4b2b (patch)
treefcb27173da478ec2bdbb412b3d75cccb93bfeab6 /lib
parentb7a55cd6c3ca0c4c97f266b72f741b980416456a (diff)
downloadzig-2b9af9e825fcbfd55f953e7c3bc80decb52a4b2b.tar.gz
zig-2b9af9e825fcbfd55f953e7c3bc80decb52a4b2b.zip
AstGen: error on unused switch label
Diffstat (limited to 'lib')
-rw-r--r--lib/std/zig/AstGen.zig5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/std/zig/AstGen.zig b/lib/std/zig/AstGen.zig
index b280360535..aa1ea2498f 100644
--- a/lib/std/zig/AstGen.zig
+++ b/lib/std/zig/AstGen.zig
@@ -7999,6 +7999,11 @@ fn switchExpr(
appendBodyWithFixupsArrayList(astgen, payloads, case_slice);
}
}
+
+ if (switch_full.label_token) |label_token| if (!block_scope.label.?.used) {
+ try astgen.appendErrorTok(label_token, "unused switch label", .{});
+ };
+
// Now that the item expressions are generated we can add this.
try parent_gz.instructions.append(gpa, switch_block);