scope(success) lowered to try-catch ?
Mike Franklin
slavo5150 at yahoo.com
Sun Jun 17 12:41:10 UTC 2018
On Sunday, 17 June 2018 at 10:58:29 UTC, Cauterite wrote:
> ---
>
> // main.d
> void main() {
> scope(success) {}
> }
>
>> dmd -betterC main.d
> Error: Cannot use try-catch statements with -betterC
>
> ---
You can see what the compiler is doing at
https://run.dlang.io/is/5BZOQV and clicking on the "AST" button.
It produces the following:
import object;
void main()
{
bool __os2 = false;
try
{
}
catch(Throwable __o3)
{
__os2 = true;
throw __o3;
}
if (!__os2)
{
}
return 0;
}
The compiler could probably lower that to something more
intelligent so it could be used in -betterC. I rule it a bug.
Mike
More information about the Digitalmars-d-learn
mailing list