From c7733eb430f10c7243d56d13c43b7b1e8c67c70c Mon Sep 17 00:00:00 2001 From: Techatrix <19954306+Techatrix@users.noreply.github.com> Date: Tue, 12 Sep 2023 02:12:50 +0200 Subject: [PATCH] add small test for error union and non optional unwrap errors --- tests/sema/error_messages/errors.zig | 2 ++ tests/sema/error_messages/optionals.zig | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 tests/sema/error_messages/errors.zig diff --git a/tests/sema/error_messages/errors.zig b/tests/sema/error_messages/errors.zig new file mode 100644 index 000000000..6d46155d2 --- /dev/null +++ b/tests/sema/error_messages/errors.zig @@ -0,0 +1,2 @@ +const ErrorUnion = type!void; +// ^^^^ error: expected error set type, found 'type' diff --git a/tests/sema/error_messages/optionals.zig b/tests/sema/error_messages/optionals.zig index ae3a7b2d0..4663e1000 100644 --- a/tests/sema/error_messages/optionals.zig +++ b/tests/sema/error_messages/optionals.zig @@ -1,9 +1,13 @@ const some_value: ?u32 = 5; const no_value: ?u32 = null; const undefined_value: ?u32 = undefined; +const not_opt_value: u32 = 0; const null_unwrap = no_value.?; // ^^^^^^^^^^ error: tried to unwrap optional of type `u32` which was null const undefined_unwrap = undefined_value.?; // ^^^^^^^^^^^^^^^^^ error: tried to unwrap optional of type `u32` which was undefined + +const invalid_unwrap = not_opt_value.?; +// ^^^^^^^^^^^^^^^ error: expected optional type, found 'u32'