diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-03-31 18:30:23 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-03-31 18:30:23 -0700 |
| commit | cec766f73c298d287c20d1bd830c159958fe177d (patch) | |
| tree | 6e7c247f87a472aff9f7c42b70da8aba5e40916b /test | |
| parent | fedc9ebd26175bf8309d665f3e1ee6769e8af86d (diff) | |
| download | zig-cec766f73c298d287c20d1bd830c159958fe177d.tar.gz zig-cec766f73c298d287c20d1bd830c159958fe177d.zip | |
stage2: compile error for duplicate switch value on boolean
Diffstat (limited to 'test')
| -rw-r--r-- | test/stage2/cbe.zig | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/test/stage2/cbe.zig b/test/stage2/cbe.zig index 2f47b8ebe8..fa8195f48a 100644 --- a/test/stage2/cbe.zig +++ b/test/stage2/cbe.zig @@ -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", .{}); |
