digitalmars.D.bugs - [Issue 5218] New: Can't implicitly convert from "abc"w to wchar[3]
- d-bugmail puremagic.com (28/28) Nov 15 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5218
- d-bugmail puremagic.com (66/66) Nov 15 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5218
- d-bugmail puremagic.com (12/12) Dec 04 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5218
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 ... 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
http://d.puremagic.com/issues/show_bug.cgi?id=5218 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch 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
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 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