http://d.puremagic.com/issues/show_bug.cgi?id=4389
--- Comment #6 from Don <clugd...@yahoo.com.au> 2011-01-19 23:59:47 PST --- Fails on D1 because dchar, wchar implicitly convert to char, even if they don't fit. PATCH: expression.c, CatAssignExp::semantic(), line 8574. The two 'else' clauses need to be swapped, so that we check for an array~char before we check for implicit conversion. { // Append array e2 = e2->castTo(sc, e1->type); type = e1->type; e = this; } ----------- SWAP THIS SECTION WITH THE NEXT ONE else if ((tb1->ty == Tarray) && e2->implicitConvTo(tb1next) ) { // Append element e2 = e2->castTo(sc, tb1next); type = e1->type; e = this; } ------- else if (tb1->ty == Tarray && (tb1next->ty == Tchar || tb1next->ty == Twchar) && e2->implicitConvTo(Type::tdchar) ) { // Append dchar to char[] or wchar[] e2 = e2->castTo(sc, Type::tdchar); type = e1->type; e = this; /* Do not allow appending wchar to char[] because if wchar happens * to be a surrogate pair, nothing good can result. */ } ----------- else { if (tb1 != Type::terror && tb2 != Type::terror) error("cannot append type %s to type %s", tb2->toChars(), tb1->toChars()); e = new ErrorExp(); } ALTERNATE PATCH: Incidentally, if dchar->char is disallowed, all DMD tests still pass. But this would probably cause existing valid code to break, so probably the first solution is better. mtype.c, line 1570, MATCH TypeBasic::implicitConvTo(Type *to) + if ((ty == Tdchar || ty == Twchar) && to->ty == Tchar) + return MATCHnomatch; + if (ty == Tdchar && to->ty == Twchar) + return MATCHnomatch; } else if (flags & TFLAGSfloating) { // Disallow implicit conversion of floating point to integer if (tob->flags & TFLAGSintegral) return MATCHnomatch; -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------