DIP 1029---Add throw as Function Attribute---Community Review Round 1
Timon Gehr
timon.gehr at gmx.ch
Thu Jan 16 08:47:01 UTC 2020
On 16.01.20 09:35, Timon Gehr wrote:
> On 16.01.20 09:04, Walter Bright wrote:
>>
>> For functions, the line is:
>>
>> sc2.stc &= ~(STC.auto_ | STC.scope_ | STC.static_ | STC.extern_ |
>> STC.abstract_ | STC.deprecated_ | STC.override_ |
>> STC.TYPECTOR | STC.final_ | STC.tls | STC.gshared |
>> STC.ref_ | STC.return_ | STC.property |
>> STC.nothrow_ | STC.pure_ | STC.safe | STC.trusted |
>> STC.system);
>>
>> https://github.com/dlang/dmd/blob/master/src/dmd/semantic3.d#L316
>>
>> Interestingly, @nogc does flow through here.
>
> This is just plain broken and cannot be explained as anything but as an
> oversight. It's the root cause of this issue:
> https://issues.dlang.org/show_bug.cgi?id=18439
>
> Why should nogc functions not be able to use the GC within lambdas that
> are executed exclusively during CTFE?
Also, alarmingly, 'pure' the same issue even though it appears in that
expression:
int bar(){ return 2; }
pure @nogc:
auto foo(){
enum x={ return bar(); }(); // error for no reason
}
pragma(msg, typeof(&foo));
I.e., the compiler contains additional logic for `pure` that makes it
broken even though there is no reason to treat it any differently to,
e.g., nothrow.
More information about the Digitalmars-d
mailing list