summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/error-handling/throw-in-defer.slang
blob: d19bf227e1b8a5bb4675584c5d2e3ec7e93b2bac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):
enum MyError
{
    Fail
}

void f() throws MyError
{
    defer {
        // Throw isn't allowed to escape defer for the same reason as 'return',
        // it'd prevent other defer statements from running. This is legal if
        // you catch it, though.
        throw MyError.Fail;
    }
}

// CHECK: error 30113