aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-06-02 15:20:51 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-06-02 15:20:51 -0400
commitb85b68a7fd175169e0f07ab733bde6d5654b1044 (patch)
tree309934a6d7db1864710ac3cdf237431f06bad8b1 /test/compile_errors.zig
parente514454c0e092794171d4a62260971cc8de6f200 (diff)
downloadzig-b85b68a7fd175169e0f07ab733bde6d5654b1044.tar.gz
zig-b85b68a7fd175169e0f07ab733bde6d5654b1044.zip
better compile error for error sets behind nullable
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 132dc8cd80..ea1357f5bb 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -3,6 +3,23 @@ const tests = @import("tests.zig");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"invalid deref on switch target",
+ \\const NextError = error{NextError};
+ \\const OtherError = error{OutOfMemory};
+ \\
+ \\export fn entry() void {
+ \\ const a: ?NextError!i32 = foo();
+ \\}
+ \\
+ \\fn foo() ?OtherError!i32 {
+ \\ return null;
+ \\}
+ ,
+ ".tmp_source.zig:5:34: error: expected 'NextError!i32', found 'OtherError!i32'",
+ ".tmp_source.zig:2:26: note: 'error.OutOfMemory' not a member of destination error set",
+ );
+
+ cases.add(
+ "invalid deref on switch target",
\\comptime {
\\ var tile = Tile.Empty;
\\ switch (tile.*) {