Files
c3c/test/unit/regression/catch_err.c3
2025-02-18 12:50:34 +01:00

21 lines
361 B
Plaintext

module catch_err @test;
fn void test()
{
anyfault a;
int! z = fn int!(anyfault* a) {
const ABC = 4;
int! x = SearchResult.MISSING?;
defer (catch err) *a = err;
return x;
}(&a);
assert(a == SearchResult.MISSING);
anyfault y;
z = fn int!(anyfault* y) {
const ABC = 4;
int! x = 1;
defer (catch err) *y = err;
return x;
}(&y);
assert(!y);
}