[Mono-list] A compiler bug?

Michal Moskal michal.moskal at gmail.com
Sun Jun 19 10:30:55 EDT 2005


On 6/19/05, Atsushi Eno <atsushi at ximian.com> wrote:
> I think this is the expected behavior. What that code actually does is:
> 
> Console.WriteLine (
>     cad1.Equals(cad2) + ",", // first argument
>     + cad2.Equals(cad3) + "," + cad1.Equals(cad3)); // second argument
> 
> The second + is interpreted as an unary operator and thus it is correct
> behavior of Console.WriteLine (since there is no {0} in the first
> argument, the second argument is just ignored).
> 
> unary plus operator associated to System.String is not a violation
> of C# specification. Note that any object can overload unary + operator.

I guess it applies to bool type, not string, it's:

  (+ cad2.Equals (cad3) + "," ...

because unary operators have very high priority.

And according to C# spec (14.6.1 Unary plus operator) there is no
unary + on bool.

So I guess this is an mcs bug.

-- 
   Michal Moskal,
   http://nemerle.org/~malekith/


More information about the Mono-list mailing list