struct S
{
~this() nothrow;
}
void test() nothrow
{
goto skip;
S r;
skip:
}
error : cannot `goto` into `try` block
test() is nothrow, S.~this() is nothrow. There should be no `try` blocks in sight... the message should be about skipping initialisation.
Comment #1 by dkorpel — 2024-10-09T15:34:27Z
The compiler rewrites things that happen on scope exit (such as destructors) into try-finally blocks. The same happens with scope guards:
```
void main()
{
goto x;
scope(exit) {}
x:
}
```
See also issue 24300. The solution is probably to add a field to the lowered AST node keeping track of where a try-finally block came from.
Comment #2 by turkeyman — 2024-10-11T08:45:27Z
Is that efficient? Does that affect optimisation opportunities in any way?
Comment #3 by robert.schadek — 2024-12-13T19:37:59Z