int[string] initHash(in string[] words) { int[string] h; for (auto i=0; i < words.length; i++) { h[words[i]] = i; // Compiler points to this line and says: //Error: non-constant expression ["abc":0,"def":1,"ghi":2] } return h; } int[string] hash3 = initHash(["abc", "def", "ghi"]);
I can't see how to do this, but I assume there's a clean way to trace back to the CallExp that's being interpreted and use that's Loc.
Actually never mind, this is the same thing as 3812, and the patch there fixes it. *** This issue has been marked as a duplicate of issue 3812 ***