Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 774

Show
Ignore:
Timestamp:
12/05/10 03:02:54 (14 years ago)
Author:
walter
Message:

bugzilla 5218 Can't implicitly convert from abcw to wchar[3]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/cast.c

    r767 r774  
    432432            {   assert(t->mod == MODimmutable); 
    433433                te = te->invariantOf(); 
    434434            } 
    435435            MATCH m2 = e->implicitConvTo(te); 
    436436            //printf("\t%s => %s, match = %d\n", e->toChars(), te->toChars(), m2); 
    437437            if (m2 < m) 
    438438                m = m2; 
    439439        } 
    440440    } 
    441441    return m; 
    442442} 
    443443#endif 
    444444 
    445445MATCH StringExp::implicitConvTo(Type *t) 
    446446{   MATCH m; 
    447447 
    448448#if 0 
    449449    printf("StringExp::implicitConvTo(this=%s, committed=%d, type=%s, t=%s)\n", 
    450450        toChars(), committed, type->toChars(), t->toChars()); 
    451451#endif 
    452     if (!committed) 
    453     { 
    454452    if (!committed && t->ty == Tpointer && t->nextOf()->ty == Tvoid) 
    455453    { 
    456454        return MATCHnomatch; 
    457455    } 
    458456    if (type->ty == Tsarray || type->ty == Tarray || type->ty == Tpointer) 
    459457    { 
    460458        TY tyn = type->nextOf()->ty; 
    461459        if (tyn == Tchar || tyn == Twchar || tyn == Tdchar) 
    462460        {   Type *tn; 
    463461            MATCH m; 
    464462 
    465463            switch (t->ty) 
    466464            { 
    467465                case Tsarray: 
    468466                    if (type->ty == Tsarray) 
    469467                    { 
    470468                        if (((TypeSArray *)type)->dim->toInteger() != 
    471469                            ((TypeSArray *)t)->dim->toInteger()) 
    472470                            return MATCHnomatch; 
    473471                        TY tynto = t->nextOf()->ty; 
    474                         if (tynto == Tchar || tynto == Twchar || tynto == Tdchar) 
     472                        if (tynto == tyn) 
     473                            return MATCHexact; 
     474                        if (!committed && (tynto == Tchar || tynto == Twchar || tynto == Tdchar)) 
    475475                            return MATCHexact; 
    476476                    } 
    477477                    else if (type->ty == Tarray) 
    478478                    { 
    479479                        if (length() > 
    480480                            ((TypeSArray *)t)->dim->toInteger()) 
    481481                            return MATCHnomatch; 
    482482                        TY tynto = t->nextOf()->ty; 
    483                         if (tynto == Tchar || tynto == Twchar || tynto == Tdchar) 
     483                        if (tynto == tyn) 
     484                            return MATCHexact; 
     485                        if (!committed && (tynto == Tchar || tynto == Twchar || tynto == Tdchar)) 
    484486                            return MATCHexact; 
    485487                    } 
    486488                case Tarray: 
    487489                case Tpointer: 
    488490                    tn = t->nextOf(); 
    489491                    m = MATCHexact; 
    490492                    if (type->nextOf()->mod != tn->mod) 
    491493                    {   if (!tn->isConst()) 
    492494                            return MATCHnomatch; 
    493495                        m = MATCHconst; 
    494496                    } 
    495497                    switch (tn->ty) 
    496498                    { 
    497499                        case Tchar: 
    498500                        case Twchar: 
    499501                        case Tdchar: 
    500                             return m; 
     502                            if (!committed) 
     503                                return m; 
     504                            break; 
    501505                    } 
    502506                    break; 
    503507            } 
    504508        } 
    505     } 
    506509    } 
    507510    return Expression::implicitConvTo(t); 
    508511#if 0 
    509512    m = (MATCH)type->implicitConvTo(t); 
    510513    if (m) 
    511514    { 
    512515        return m; 
    513516    } 
    514517 
    515518    return MATCHnomatch; 
    516519#endif 
    517520} 
    518521 
    519522MATCH ArrayLiteralExp::implicitConvTo(Type *t) 
    520523{   MATCH result = MATCHexact; 
    521524 
    522525#if 0 
    523526    printf("ArrayLiteralExp::implicitConvTo(this=%s, type=%s, t=%s)\n", 
    524527        toChars(), type->toChars(), t->toChars()); 
    525528#endif