authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-08 22:44:15-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-08 22:44:15-05:00
log4b16874f04b7bae48a32da582af39667a3ef731d
tree82a0d6a7047f312ea014eeff22d959361c629745
parentee982ae162901078458003fad169ddb1cf4d1d06

add test for comptime err to int with only 1 member of set


2 files changed, 10 insertions(+), 10 deletions(-)

TODO deleted-10
......@@ -1,10 +0,0 @@
1comptime calling fn with inferred error set should give empty error set but still you can use try
2
3comptime err to int of empty err set and of size 1 err set
4
5
6undefined in infer error
7
8syntax - (error{}!void) as the return type
9
10
test/cases/error.zig+10
......@@ -140,3 +140,13 @@ test "syntax: nullable operator in front of error union operator" {
140140 assert(?error!i32 == ?(error!i32));
141141 }
142142}
143
144test "comptime err to int of error set with only 1 possible value" {
145 testErrToIntWithOnePossibleValue(error.A, u32(error.A));
146 comptime testErrToIntWithOnePossibleValue(error.A, u32(error.A));
147}
148fn testErrToIntWithOnePossibleValue(x: error{A}, comptime value: u32) void {
149 if (u32(x) != value) {
150 @compileError("bad");
151 }
152}