gcc/testsuite/gdc.test/fail_compilation/test21443.d
raw| 1 | // https://issues.dlang.org/show_bug.cgi?id=21443 |
| 2 | // REQUIRED_ARGS: -de |
| 3 | |
| 4 | /* |
| 5 | TEST_OUTPUT: |
| 6 | --- |
| 7 | fail_compilation/test21443.d(14): Deprecation: `return` statements cannot be in `scope(failure)` bodies. |
| 8 | fail_compilation/test21443.d(14): Use try-catch blocks for this purpose |
| 9 | --- |
| 10 | */ |
| 11 | |
| 12 | ulong get () @safe nothrow |
| 13 | { |
| 14 | scope (failure) return 10; |
| 15 | throw new Error(""); |
| 16 | } |
| 17 | |
| 18 | void main () @safe |
| 19 | { |
| 20 | assert(get() == 10); // passes |
| 21 | } |