From 4b16874f04b7bae48a32da582af39667a3ef731d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 8 Feb 2018 22:44:15 -0500 Subject: [PATCH] add test for comptime err to int with only 1 member of set --- TODO | 10 ---------- test/cases/error.zig | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 TODO diff --git a/TODO b/TODO deleted file mode 100644 index 5da999b457..0000000000 --- a/TODO +++ /dev/null @@ -1,10 +0,0 @@ -comptime calling fn with inferred error set should give empty error set but still you can use try - -comptime err to int of empty err set and of size 1 err set - - -undefined in infer error - -syntax - (error{}!void) as the return type - - diff --git a/test/cases/error.zig b/test/cases/error.zig index 61e0b375a2..bb1366429b 100644 --- a/test/cases/error.zig +++ b/test/cases/error.zig @@ -140,3 +140,13 @@ test "syntax: nullable operator in front of error union operator" { assert(?error!i32 == ?(error!i32)); } } + +test "comptime err to int of error set with only 1 possible value" { + testErrToIntWithOnePossibleValue(error.A, u32(error.A)); + comptime testErrToIntWithOnePossibleValue(error.A, u32(error.A)); +} +fn testErrToIntWithOnePossibleValue(x: error{A}, comptime value: u32) void { + if (u32(x) != value) { + @compileError("bad"); + } +}