[Mono-list] A compiler bug?
Atsushi Eno
atsushi at ximian.com
Sun Jun 19 10:53:38 EDT 2005
Oops, I was wrong, besides the operator/expression resolution priority
you pointed out. In the spec 14.2.3, case of lack of "single best
operator" a compile time error should occur. I only read 14.6.1 and
thought that they are just predefined ones.
I'll file it to bugzilla. Thanks.
Atsushi Eno
> > 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.
>
More information about the Mono-list
mailing list