[Mono-bugs] [Bug 81110][Nor] New - User operators are ignored for implicit conversions

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Mar 11 09:18:46 EDT 2007


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 marek.safar at seznam.cz.

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

--- shadow/81110	2007-03-11 08:18:46.000000000 -0500
+++ shadow/81110.tmp.26373	2007-03-11 08:18:46.000000000 -0500
@@ -0,0 +1,232 @@
+Bug#: 81110
+Product: Mono: Compilers
+Version: 1.2
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: marek.safar at seznam.cz               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: User operators are ignored for implicit conversions
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+We are missing probing for user operators.
+
+
+Steps to reproduce the problem:
+1. 
+
+using System;
+
+class A
+{
+	public static implicit operator sbyte (A mask)
+	{
+		return 1;
+	}
+
+	public static implicit operator byte (A mask)
+	{
+		return 2;
+	}
+	
+	public static implicit operator short (A mask)
+	{
+		return 3;
+	}
+
+	public static implicit operator ushort (A mask)
+	{
+		return 4;
+	}
+	
+	public static implicit operator int (A mask)
+	{
+		return 5;
+	}
+
+	public static implicit operator uint (A mask)
+	{
+		return 6;
+	}
+	
+	public static implicit operator long (A mask)
+	{
+		return 7;
+	}
+
+	public static implicit operator ulong (A mask)
+	{
+		return 8;
+	}
+}
+
+class A2
+{
+	public static implicit operator sbyte (A2 mask)
+	{
+		return 1;
+	}
+
+	public static implicit operator byte (A2 mask)
+	{
+		return 2;
+	}
+	
+	public static implicit operator short (A2 mask)
+	{
+		return 3;
+	}
+
+	public static implicit operator uint (A2 mask)
+	{
+		return 6;
+	}
+	
+	public static implicit operator long (A2 mask)
+	{
+		return 7;
+	}
+
+	public static implicit operator ulong (A2 mask)
+	{
+		return 8;
+	}
+}
+
+class A3
+{
+	public static implicit operator sbyte (A3 mask)
+	{
+		return 1;
+	}
+
+	public static implicit operator uint (A3 mask)
+	{
+		return 6;
+	}
+	
+	public static implicit operator long (A3 mask)
+	{
+		return 7;
+	}
+
+	public static implicit operator ulong (A3 mask)
+	{
+		return 8;
+	}
+}
+
+class A4
+{
+	public static implicit operator uint (A4 mask)
+	{
+		return 6;
+	}
+	
+	public static implicit operator long (A4 mask)
+	{
+		return 7;
+	}
+
+	public static implicit operator ulong (A4 mask)
+	{
+		return 8;
+	}
+}
+
+class A5
+{
+	public static implicit operator uint (A5 mask)
+	{
+		return 6;
+	}
+
+	public static implicit operator ulong (A5 mask)
+	{
+		return 8;
+	}
+}
+
+class A6
+{
+	public static implicit operator byte (A6 mask)
+	{
+		return 2;
+	}
+}
+
+
+public class Constraint
+{
+	public static int Main ()
+	{
+		A a = null;
+		A2 a2 = null;
+		A3 a3 = null;
+		A4 a4 = null;
+		A5 a5 = null;
+		A6 a6 = null;
+		
+		Console.WriteLine (-a);
+		Console.WriteLine (-a2);
+		Console.WriteLine (-a3);
+		Console.WriteLine (-a4);
+		Console.WriteLine (-a5);
+		Console.WriteLine (-a6);
+		
+		Console.WriteLine (~a);
+		Console.WriteLine (~a2);
+		Console.WriteLine (~a3);
+		Console.WriteLine (~a4);
+		Console.WriteLine (~a5);
+		Console.WriteLine (~a6);
+		return 0;
+	}
+	
+}
+
+Actual Results:
+
+test-op.cs(156,36): error CS0023: The `-' operator cannot be applied to
+operand of type `A4'
+test-op.cs(157,36): error CS0023: The `-' operator cannot be applied to
+operand of type `A5'
+test-op.cs(163,36): error CS0023: The `~' operator cannot be applied to
+operand of type `A4'
+test-op.cs(164,36): error CS0023: The `~' operator cannot be applied to
+operand of type `A5'
+
+
+Expected Results:
+
+The program should compile and run producing following output.
+
+-5
+-3
+-1
+-7
+-6
+-2
+-6
+-4
+-2
+4294967289
+4294967289
+-3
+
+
+How often does this happen? 
+
+
+Additional Information:


More information about the mono-bugs mailing list