digitalmars.D.learn - goto finally - fail. Why?
- Brother Bill (41/41) Aug 19 If change 'finally' to 'finally1' in both places, it compiles and
- monkyyy (2/7) Aug 19 its a try-catch keyword
- Brother Bill (3/11) Aug 19 That's it! It's works exactly like C# too. Same 'finally'
If change 'finally' to 'finally1' in both places, it compiles and
runs.
Why does 'finally' break compilation?
Is this a BUG or a FEATURE?
From: Programming in D book, page 511.
Error:
```
c:\dev\D\71 -
80\c76_1c_c_style_code_not_needed_in_D\source\app.d(12): Error:
identifier expected following `goto`
goto finally;
^
c:\dev\D\71 -
80\c76_1c_c_style_code_not_needed_in_D\source\app.d(12): Error:
found `finally` when expecting `;` following `goto` statement
goto finally;
^
c:\dev\D\71 -
80\c76_1c_c_style_code_not_needed_in_D\source\app.d(17): Error:
found `finally` instead of statement
finally:
^
```
source/app.d
```
import std.stdio;
void main() {
writeln("foo() is: ", foo());
}
// --- C code --
int foo() {
int error = 42;
if (error) {
goto finally;
}
error = 86;
finally:
// ... cleanup operations ...
return error;
}
```
Aug 19
On Tuesday, 19 August 2025 at 20:38:52 UTC, Brother Bill wrote:If change 'finally' to 'finally1' in both places, it compiles and runs. Why does 'finally' break compilation? Is this a BUG or a FEATURE? [...]its a try-catch keyword
Aug 19
On Tuesday, 19 August 2025 at 20:40:47 UTC, monkyyy wrote:On Tuesday, 19 August 2025 at 20:38:52 UTC, Brother Bill wrote:keyword.If change 'finally' to 'finally1' in both places, it compiles and runs. Why does 'finally' break compilation? Is this a BUG or a FEATURE? [...]its a try-catch keyword
Aug 19








Brother Bill <brotherbill mail.com>