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


Rainer Schuetze <r.sagita...@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, rejects-valid
                 CC|                            |r.sagita...@gmx.de
           Severity|normal                      |regression


--- Comment #1 from Rainer Schuetze <r.sagita...@gmx.de> 2009-12-29 03:47:45 
PST ---
A much simpler version also fails:

void main()
{
    int[int] s;
    s = s.init;
}

c:\l\dmd-2.036\windows\bin\..\..\src\druntime\import\object.di(294): Error:
cann
ot implicitly convert expression
(_D6object26__T16AssociativeArrayTiTiZ16Associa
tiveArray6__initZ) of type AssociativeArray!(int,int) to int[int]

This used to work for DMD 2.035, so it is a regression.

There seems to be some inconsistency whether to use the new implementation of
associative arrays or the original type.

The following patch ensures usage of the library type for implicitely casting.

Index: mtype.c
===================================================================
--- mtype.c    (revision 317)
+++ mtype.c    (working copy)
@@ -6761,6 +6761,9 @@
 {   MATCH m;

     //printf("TypeStruct::implicitConvTo(%s => %s)\n", toChars(),
to->toChars());
+    if(to->ty == Taarray)
+    to = ((TypeAArray*)to)->getImpl()->type;
+
     if (ty == to->ty && sym == ((TypeStruct *)to)->sym)
     {    m = MATCHexact;        // exact match
     if (mod != to->mod)

Index: e2ir.c
===================================================================
--- e2ir.c    (revision 317)
+++ e2ir.c    (working copy)
@@ -3508,6 +3508,12 @@
     elem *e = e1->toElem(irs);
     Type *tfrom = e1->type->toBasetype();
     Type *t = to->toBasetype();        // skip over typedef's
+
+    if(tfrom->ty == Taarray)
+    tfrom = ((TypeAArray*)tfrom)->getImpl()->type;
+    if(t->ty == Taarray)
+    t = ((TypeAArray*)t)->getImpl()->type;
+
     if (t->equals(tfrom))
     goto Lret;

This causes some strange cast (pointer to AA - is this supposed to work?) in
object.d to fail, but I could not find the place where this magic happens. So I
changed the definition :

Index: object.di
===================================================================
--- object.di    (revision 222)
+++ object.di    (working copy)
@@ -300,5 +300,7 @@

     Value[Key] rehash() @property
     {
-        return cast(Value[Key]) _aaRehash(&p, typeid(Value[Key]));
+    Value[Key] aa;
+    aa.p = _aaRehash(&p, typeid(Value[Key]));
+        return aa;
     }

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

Reply via email to