aboutsummaryrefslogtreecommitdiff
path: root/test/cases
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-02-08 22:18:13 -0500
committerAndrew Kelley <superjoe30@gmail.com>2018-02-08 22:18:13 -0500
commit0efe441dfd422d4bfe501d5fbfbf15bd5951b494 (patch)
treefb04d5fe84ebb766358331ca267467d22bc22193 /test/cases
parent54c06bf7158ce52c5de8d09f109215c467a3bf6a (diff)
downloadzig-0efe441dfd422d4bfe501d5fbfbf15bd5951b494.tar.gz
zig-0efe441dfd422d4bfe501d5fbfbf15bd5951b494.zip
if statements support comptime known test error, runtime payload
Diffstat (limited to 'test/cases')
-rw-r--r--test/cases/error.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/cases/error.zig b/test/cases/error.zig
index 3d2835e723..a8150620b2 100644
--- a/test/cases/error.zig
+++ b/test/cases/error.zig
@@ -123,3 +123,14 @@ fn testExplicitErrorSetCast(set1: Set1) void {
var y = Set1(x);
assert(y == error.A);
}
+
+test "comptime test error for empty error set" {
+ testComptimeTestErrorEmptySet(1234);
+ comptime testComptimeTestErrorEmptySet(1234);
+}
+
+const EmptyErrorSet = error {};
+
+fn testComptimeTestErrorEmptySet(x: EmptyErrorSet!i32) void {
+ if (x) |v| assert(v == 1234) else |err| @compileError("bad");
+}