diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-07-26 15:39:47 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-07-26 23:29:54 +0300 |
| commit | d6e3988fe846864a33adf9f5f04d800718b31392 (patch) | |
| tree | e6678d0b0cc5c51f75112e19191de6d56dbe1914 /test/cases/compile_errors/nested_error_set_mismatch.zig | |
| parent | 7862ab9f410d20d0cfe799bf025f8cf57dd6f15a (diff) | |
| download | zig-d6e3988fe846864a33adf9f5f04d800718b31392.tar.gz zig-d6e3988fe846864a33adf9f5f04d800718b31392.zip | |
Sema: better error when coercing error sets
Diffstat (limited to 'test/cases/compile_errors/nested_error_set_mismatch.zig')
| -rw-r--r-- | test/cases/compile_errors/nested_error_set_mismatch.zig | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/cases/compile_errors/nested_error_set_mismatch.zig b/test/cases/compile_errors/nested_error_set_mismatch.zig new file mode 100644 index 0000000000..c0d68a5e53 --- /dev/null +++ b/test/cases/compile_errors/nested_error_set_mismatch.zig @@ -0,0 +1,19 @@ +const NextError = error{NextError}; +const OtherError = error{OutOfMemory}; + +export fn entry() void { + const a: ?NextError!i32 = foo(); + _ = a; +} + +fn foo() ?OtherError!i32 { + return null; +} + +// error +// backend=llvm +// target=native +// +// :4:1: error: expected type '?error{NextError}!i32', found '?error{OutOfMemory}!i32' +// :4:1: note: optional type child 'error{OutOfMemory}!i32' cannot cast into optional type child 'error{NextError}!i32' +// :4:1: note: 'error.OutOfMemory' not a member of destination error set |
