[Issue 5279] Function-static associative arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 27 07:31:37 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5279
SomeDude <lovelydear at mailmetrash.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lovelydear at mailmetrash.com
--- Comment #7 from SomeDude <lovelydear at mailmetrash.com> 2012-04-27 07:32:41 PDT ---
The following program doesn't compile with 2.059:
import std.stdio, std.container, std.range;
string[char] aa = ['f':"foo", 'b':"bar"];
void main(){
foreach (ch, str; aa) {
writefln("[%s]: [%s]", ch, str);
}
}
It gives:
PS E:\DigitalMars\dmd2\samples> rdmd -O -inline bug.d
bug.d(3): Error: non-constant expression ['f':"foo",'b':"bar"]
PS E:\DigitalMars\dmd2\samples>
This also happens with the following:
const string[char] aa = ['f': "foo",'b': "bar"];
static const string[char] aa = ['f': "foo",'b': "bar"];
immutable string[char] aa = ['f': "foo",'b': "bar"];
static immutable string[char] aa = ['f': "foo",'b': "bar"];
Only this compiles:
enum string[char] aa = ['f': "foo",'b': "bar"];
--
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