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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Empty array literals with   |Appending empty array using
                   |explicit type implicitly    |~= cast(T[]) [] doesn't
                   |convert to any array type   |work


--- Comment #8 from Stewart Gordon <s...@iname.com> 2012-02-03 17:10:48 PST ---
The recent change to the summary line is wrong.

If they merely implicitly converted to any array type, the original code would
behave correctly, because the semantic analyser always attempts an exact match
before an implicit conversion match.  Clearly something else is going on.

(DMD 2.057 Win32)
----- bz2006.d -----
import std.stdio;

pragma(msg, typeof(cast(string[]) []));

void main() {
    string[][] aas = [];
    aas ~= cast(string[]) [];
    writefln("%d", aas.length);
    aas ~= (string[]).init;
    writefln("%d", aas.length);
    aas = aas ~ cast(string[]) [];
    writefln("%d", aas.length);

    auto empty = cast(string[]) [];
    pragma(msg, typeof(empty));
    aas ~= empty;
    writefln("%d", aas.length);
}
----------
C:\Users\Stewart\Documents\Programming\D\Tests\bugs>dmd bz2006.d
string[]
string[]

C:\Users\Stewart\Documents\Programming\D\Tests\bugs>bz2006
0
1
2
3
----------

Going by this, the problem seems to occur only with this specific
representation of an empty array, and only when it is applied directly to ~=
and not passed through a variable.

So it isn't an implicit conversion problem.  It would seem that DMD
special-cases this form, but this special-casing is broken.

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

Reply via email to