Skip to content

Commit 594c5c7

Browse files
committed
add behavior test for empty error set inference
closes #1386 closes #7541
1 parent 799cc2c commit 594c5c7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/behavior/error.zig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,27 @@ test "inferred empty error set comptime catch" {
287287
S.foo() catch @compileError("fail");
288288
}
289289

290+
test "error inference with an empty set" {
291+
const S = struct {
292+
const Struct = struct {
293+
pub fn func() (error{})!usize {
294+
return 0;
295+
}
296+
};
297+
298+
fn AnotherStruct(comptime SubStruct: type) type {
299+
return struct {
300+
fn anotherFunc() !void {
301+
try expect(0 == (try SubStruct.func()));
302+
}
303+
};
304+
}
305+
};
306+
307+
const GeneratedStruct = S.AnotherStruct(S.Struct);
308+
try GeneratedStruct.anotherFunc();
309+
}
310+
290311
test "error union peer type resolution" {
291312
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
292313
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO

0 commit comments

Comments
 (0)