[Issue 6238] Cannot define global immutable AA
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Feb 3 22:54:33 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6238
--- Comment #3 from hsteoh at quickfur.ath.cx 2012-02-03 22:54:32 PST ---
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"]);
Or is this a case of the compiler trying to be helpful and giving a misleading
error message? (I.e. the error is supposed to be on the line that initializes
hash3, but the compiler is pointing to the cause of the supposed non-constancy
of the value.)
I tried changing initHash() to construct a hash literal as a string and using
mixin() to initialize hash3, but that didn't work either.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list