[Issue 15125] Explicit pure needed even though pure: at the top of the file

2022-10-13 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15125

RazvanN  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

--


[Issue 15125] Explicit pure needed even though pure: at the top of the file

2018-05-28 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15125

RazvanN  changed:

   What|Removed |Added

 CC||razvan.nitu1...@gmail.com

--- Comment #1 from RazvanN  ---
Although I cannot find any documentation about it, from what my experience
using pure:, safe:, extern(something):, nogc:, nothrow: works only for
top-level declaration (does not include the inner scopes of
aggregateDeclarations).

In your specific case pure and safe are applied to the MyExceptionClass but
since safe and pure do not make sense for classes, they are silently ignored
(not propagated to member functions).

I have no idea if this is the intended behavior or not, but in my opinion,
dmd's policy to silently ignore attributes when they do not make sense is not a
good one.

Other notable cases:

extern(C) class A {} // compiler accepts it and ignores extern(C) 

pure class A {}  // again no problem, but pure is not propagated to A's 
 // methods

@safe class A {} // ditto

The explanation for this is that you can use `$attribute`: at the top of the
module and only the declarations that make sense in conjunction with that
attribute will be affected and changing this to actually issuing an error for
those that don't would break too much code. I tried doing this for `extern(C)
class` and look at the result [1].

In conclusion, this will most likely be closed as WONTFIX.

[1] https://github.com/dlang/dmd/pull/7229

--


[Issue 15125] Explicit pure needed even though pure: at the top of the file

2017-07-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15125

Vladimir Panteleev  changed:

   What|Removed |Added

   Keywords||spec
   Hardware|x86_64  |All
 OS|Linux   |All

--