Why allow initializers of non-static members that allocate?

Steven Schveighoffer schveiguy at gmail.com
Fri Jun 10 18:09:48 UTC 2022


On 6/10/22 1:20 PM, Mike Parker wrote:
> On Friday, 10 June 2022 at 14:56:24 UTC, Steven Schveighoffer wrote:
> 
>> Discovered circa 2009: https://issues.dlang.org/show_bug.cgi?id=2947
>>
>> It should be illegal to declare a field this way that has mutable 
>> references without being `shared`. End of story.
>>
> 
> The docs do say that:
> 
>> The default initializers may not contain references to mutable data.

I guess it was added but no implementation done for it? There's not even 
a warning!

https://github.com/dlang/dlang.org/pull/2331/files#diff-dee70e840ada3a820b3a373d649812b1157fd584ed0837e4a937ea3418f093e3R157

Anyways, a documented rule that's so easily enforced but is not actually 
enforced is pretty worthless.

-Steve


More information about the Digitalmars-d-learn mailing list