[Mono-bugs] [Bug 80315][Nor] New - More implicit casts not considered with compound assignments

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Dec 19 09:45:40 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=80315

--- shadow/80315	2006-12-19 09:45:40.000000000 -0500
+++ shadow/80315.tmp.5697	2006-12-19 09:45:40.000000000 -0500
@@ -0,0 +1,58 @@
+Bug#: 80315
+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: More implicit casts not considered with compound assignments
+
+Description of Problem:
+
+Weird case not fixed by bug80313:
+
+using System;
+
+namespace Bugs
+{
+    class Bug2
+    {
+        struct MyByte
+        {
+            private byte value;
+            public MyByte(byte value)
+            {
+                this.value = value;
+            }
+            public static implicit operator MyByte(byte value)
+            {
+                return new MyByte(value);
+            }
+            public static implicit operator byte(MyByte b)
+            {
+                return b.value;
+            }
+        }
+
+        public static void Main(string[] args)
+        {
+            MyByte b = 255;
+            b += 255;
+            Console.WriteLine(b);
+        }
+    }
+}
+
+Assignment "b += 255" fails although 255 is implicitely
+convertible to MyByte.
+bug2.cs(27,13): error CS0031: Constant value `int' cannot be converted to a
+`Bugs.Bug2.MyByte'


More information about the mono-bugs mailing list