[Mono-bugs] [Bug 80288][Nor] New - Implicit casts not considered with binary operators
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Sun Dec 17 15:38:51 EST 2006
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by martin.voelkle at gmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=80288
--- shadow/80288 2006-12-17 15:38:51.000000000 -0500
+++ shadow/80288.tmp.18982 2006-12-17 15:38:51.000000000 -0500
@@ -0,0 +1,68 @@
+Bug#: 80288
+Product: Mono: Compilers
+Version: 1.2
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com
+ReportedBy: martin.voelkle at gmail.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Implicit casts not considered with binary operators
+
+Description of Problem:
+
+It's quite hard to explain in english, so here is a test case:
+
+using System;
+
+namespace Bugs
+{
+ class Bug0
+ {
+ struct MyBoolean
+ {
+ private bool value;
+ public MyBoolean(bool value)
+ {
+ this.value = value;
+ }
+ public static implicit operator MyBoolean(bool value)
+ {
+ return new MyBoolean(value);
+ }
+ public static implicit operator bool(MyBoolean b)
+ {
+ return b.value;
+ }
+ }
+
+ public static void Main()
+ {
+ MyBoolean b = true;
+ if (true && b)
+ {
+ Console.WriteLine("true");
+ }
+ else
+ {
+ Console.WriteLine("false");
+ }
+ }
+ }
+}
+
+This code doesn't compile with mcs or gmcs (1.2.2.1), giving this error:
+
+Bug0.cs(27,17): error CS0019: Operator `&&' cannot be applied to operands
+of type `bool' and `Bugs.Bug0.Boolean'
+
+The trouble lies in the "true && b" expression, because the implicit
+conversion to bool is not considered (visual c# 2005 handles it without any
+problem).
More information about the mono-bugs
mailing list