Please fix `.init` property

Hipreme msnmancini at hotmail.com
Sun Jan 7 23:12:30 UTC 2024


I was doing a completely functional code, then I noticed some 
variable changing abruptly to a strange value. After the first 
run in a function, the value completely changed, I've reduced and 
found that I was able to actually modify `.init`.

```d
struct MyTest
{
     string[] dirs = ["source"];
}

void DoIt(ref MyTest a )
{
     a.dirs[0] = null;
}

void main()
{
     MyTest t;
     DoIt(t);
     MyTest t2;
     assert(t2.dirs == MyTest.init.dirs); //Crashes
}
```

Looks like everyone knew this bug existed, but it caused me waste 
4 hours trying to find when did it happen. I can't understand why 
this has not been fixed yet, but this leads to extremely erratic 
behaviour, which I'm going to do an ugly workaround.

Since we are on a year of stability, I think getting this kind of 
bug fixed could be a priority.


More information about the Digitalmars-d mailing list