AstGen: error on unused switch label
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@ comptime {
|
||||
comptime {
|
||||
blk: for (@as([0]void, undefined)) |_| {}
|
||||
}
|
||||
comptime {
|
||||
blk: switch (true) {
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
// error
|
||||
// target=native
|
||||
@@ -35,3 +40,4 @@ comptime {
|
||||
// :17:5: error: unused block label
|
||||
// :20:5: error: unused while loop label
|
||||
// :23:5: error: unused for loop label
|
||||
// :26:5: error: unused switch label
|
||||
|
||||
Reference in New Issue
Block a user