http://d.puremagic.com/issues/show_bug.cgi?id=6253


Stewart Gordon <s...@iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |s...@iname.com


--- Comment #2 from Stewart Gordon <s...@iname.com> 2012-01-07 06:38:51 PST ---
> (In reply to comment #0)
> This program:
> 
> void main() {
>     bool[int[]] aa;
>     aa[[1, 2]] = true; // line 3
> }
> 
> With DMD 2.053 gives a compile time-error:
> test.d(3): Error: associative arrays can only be assigned values 
> with immutable keys, not int[]

If all the elements of an array literal bind to immutable types, then 
so ought to whole array literal.

> I think this is bad, and not intuitive.  I suggest to make DMD 
> refuse this definition too:
> bool[int[]] aa;

Agreed.

> And accept this, and similar:
> bool[const(int)[]] aa;

Which should actually declare aa to be a bool[immutable(int)[]], 
given that that's the only thing it will allow you to put in.

BTW the current behaviour (DMD 2.056) is actually rather weird:
----------
pragma(msg, (bool[int[]]).stringof);
pragma(msg, (bool[const(int)[]]).stringof);
pragma(msg, (bool[immutable(int)[]]).stringof);
pragma(msg, (bool[const(int[])]).stringof);
pragma(msg, (bool[immutable(int[])]).stringof);
----------
C:\Users\Stewart\Documents\Programming\D\d2\tests>dmd -c aa_array_param_type.d
bool[const(int)[]]
bool[const(int)[]]
bool[immutable(int)[]]
bool[const(int)[]]
bool[immutable(int[])]
----------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to