ldc-developers/ldc — Issue #13: Access violoation
Author: bioinfornatics
Created: 2011-10-26 22:47:10+00:00
State: open

they are a problem around private var, below code:

```D
private import std.array : split;
private import std.stdio : writeln;
private import std.string : format, stripLeft, stripRight;

class Container{
private:
string[string] dict;
string name;
this( string name ){
this.name = name;
this.dict = dict;
}
}
void main( string[] args ){
string[]words = split(cast(string)"key=value", "=");
foreach( ref string word; words )
word.stripRight().stripLeft();

Container c = new Container("test");
c.dict[words[0]] = words[1];
writeln( "strange access to private var!!!" );
writeln( c.dict );
writeln( c.dict["key"] );
writeln( c.dict.keys );
}
```

poduce this output:

```bash
$ ./test
strange access to private var!!!
["key":"value"]
[jonathan@jonathan ~]$ ldc2 test.d
[jonathan@jonathan ~]$ ./test
strange access to private var!!!
["key":"value"]
value
["key"]
```