www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5218] New: Can't implicitly convert from "abc"w to wchar[3]

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5218

           Summary: Can't implicitly convert from "abc"w to wchar[3]
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: clugdbug yahoo.com.au


--- Comment #0 from Don <clugdbug yahoo.com.au> 2010-11-15 13:09:39 PST ---
... though you can with char. This code also worked in D1.
---
void bug5218c(char [3] s) {}
void bug5218w(wchar [3] s) {}
void bug5218d(dchar [3] s) {}

void main()
{    
    bug5218c("abc");
    bug5218w("abc"w);
    bug5218d("abc"d);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 15 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5218


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #1 from Don <clugdbug yahoo.com.au> 2010-11-15 15:36:06 PST ---
PATCH: This is because "abc"w and "abc"d are committed types. If the type is
committed, implicit conversions are not performed at all. But this is wrong:
they should still allow const/immutable conversions.



Index: cast.c
===================================================================
--- cast.c    (revision 755)
+++ cast.c    (working copy)
   -449,8 +449,6   
     printf("StringExp::implicitConvTo(this=%s, committed=%d, type=%s,
t=%s)\n",
         toChars(), committed, type->toChars(), t->toChars());
 #endif
-    if (!committed)
-    {
     if (!committed && t->ty == Tpointer && t->nextOf()->ty == Tvoid)
     {
         return MATCHnomatch;
   -471,7 +469,8   
                             ((TypeSArray *)t)->dim->toInteger())
                             return MATCHnomatch;
                         TY tynto = t->nextOf()->ty;
-                        if (tynto == Tchar || tynto == Twchar || tynto ==
Tdchar)
+                        if (tynto == tyn) return MATCHexact;
+                        if (!committed && (tynto == Tchar || tynto == Twchar
|| tynto == Tdchar))
                             return MATCHexact;
                     }
                     else if (type->ty == Tarray)
   -480,7 +479,8   
                             ((TypeSArray *)t)->dim->toInteger())
                             return MATCHnomatch;
                         TY tynto = t->nextOf()->ty;
-                        if (tynto == Tchar || tynto == Twchar || tynto ==
Tdchar)
+                        if (tynto == tyn) return MATCHexact;
+                        if (!committed && (tynto == Tchar || tynto == Twchar
|| tynto == Tdchar))
                             return MATCHexact;
                     }
                 case Tarray:
   -497,13 +497,13   
                         case Tchar:
                         case Twchar:
                         case Tdchar:
-                            return m;
+                            if (!committed)
+                                return m;
                     }
                     break;
             }
         }
     }
-    }
     return Expression::implicitConvTo(t);
 #if 0
     m = (MATCH)type->implicitConvTo(t);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 15 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5218


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


--- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2010-12-04
19:03:11 PST ---
http://www.dsource.org/projects/dmd/changeset/774

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