[Mono-bugs] [Bug 79070][Nor] New - Implicit conversion to decimal on both operands

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Aug 13 13:10:48 EDT 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 kwolfli at yahoo.de.

http://bugzilla.ximian.com/show_bug.cgi?id=79070

--- shadow/79070	2006-08-13 13:10:48.000000000 -0400
+++ shadow/79070.tmp.5087	2006-08-13 13:10:48.000000000 -0400
@@ -0,0 +1,37 @@
+Bug#: 79070
+Product: Mono: Compilers
+Version: 1.0
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: kwolfli at yahoo.de               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Implicit conversion to decimal on both operands
+
+The following code will compile with Microsoft csc, but mcs aborts  
+compilation with "test.cs(9,34): error CS0019: Operator `+' cannot be  
+applied to operands of type `MyDecimal' and `MyDecimal'". The same code  
+works with mcs if I change decimal to int, so (for whatever reason, I 
+couldn't find one in the C# specification) this behaviour depends on the 
+type. 
+  
+   
+class MyDecimal {   
+    public static implicit operator decimal(MyDecimal i) { return 42; }   
+}   
+   
+class TestProgram {   
+    static void Main(string[] args)   
+    {   
+        MyDecimal a = new MyDecimal(), b = new MyDecimal();   
+        System.Console.WriteLine(a + b);   
+    }   
+}


More information about the mono-bugs mailing list