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 [EMAIL PROTECTED]

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: [EMAIL PROTECTED]                            
+ReportedBy: [EMAIL PROTECTED]               
+QAContact: [EMAIL PROTECTED]
+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).
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to