Mercurial > projects > ddmd
diff dmd/EqualExp.d @ 79:43073c7c7769
updated to 2.035
also implemented a few missing functions
still crashes in Import.importAll though
author | Trass3r |
---|---|
date | Mon, 30 Aug 2010 03:57:51 +0200 |
parents | 2e2a5c3f943a |
children | e28b18c23469 |
line wrap: on
line diff
--- a/dmd/EqualExp.d Sun Aug 29 14:39:08 2010 +0100 +++ b/dmd/EqualExp.d Mon Aug 30 03:57:51 2010 +0200 @@ -1,5 +1,6 @@ module dmd.EqualExp; +import dmd.ErrorExp; import dmd.Expression; import dmd.Id; import dmd.Identifier; @@ -42,8 +43,6 @@ override Expression semantic(Scope sc) { Expression e; - Type t1; - Type t2; //printf("EqualExp.semantic('%s')\n", toChars()); if (type) @@ -74,7 +73,9 @@ } } - if (e1.type.toBasetype().ty == TY.Tclass && e2.op == TOK.TOKnull || e2.type.toBasetype().ty == TY.Tclass && e1.op == TOK.TOKnull) + Type t1 = e1.type.toBasetype(); + Type t2 = e2.type.toBasetype(); + if (t1.ty == TY.Tclass && e2.op == TOK.TOKnull || t2.ty == TY.Tclass && e1.op == TOK.TOKnull) { error("use '%s' instead of '%s' when comparing with null", Token.toChars(op == TOK.TOKequal ? TOK.TOKidentity : TOK.TOKnotidentity), @@ -96,6 +97,14 @@ } } + // Disallow comparing T[]==T and T==T[] + if (e1.op == TOKslice && t1.ty == Tarray && e2.implicitConvTo(t1.nextOf()) || + e2.op == TOKslice && t2.ty == Tarray && e1.implicitConvTo(t2.nextOf())) + { + incompatibleTypes(); + return new ErrorExp(); + } + e = typeCombine(sc); type = Type.tboolean;