stage2: compile error for duplicate switch value on boolean

This commit is contained in:
Andrew Kelley
2021-03-31 18:30:23 -07:00
parent fedc9ebd26
commit cec766f73c
4 changed files with 61 additions and 61 deletions
+15 -1
View File
@@ -327,7 +327,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\}
, "");
// Switch expression has duplicate case value.
// Integer switch expression has duplicate case value.
case.addError(
\\export fn main() c_int {
\\ var cond: c_int = 0;
@@ -345,6 +345,20 @@ pub fn addCases(ctx: *TestContext) !void {
":8:13: error: duplicate switch value",
":6:15: note: previous value here",
});
// Boolean switch expression has duplicate case value.
case.addError(
\\export fn main() c_int {
\\ var a: bool = false;
\\ const b: c_int = switch (a) {
\\ false => 1,
\\ true => 2,
\\ false => 3,
\\ };
\\}
, &.{
":6:9: error: duplicate switch value",
});
}
//{
// var case = ctx.exeFromCompiledC("optionals", .{});