[Mono-bugs] [Bug 52492][Nor] New - We do not detect CS0034 in the presence of implicit conversions

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 7 Feb 2004 12:48:55 -0500 (EST)


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 miguel@ximian.com.

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

--- shadow/52492	2004-02-07 12:48:54.000000000 -0500
+++ shadow/52492.tmp.21715	2004-02-07 12:48:55.000000000 -0500
@@ -0,0 +1,63 @@
+Bug#: 52492
+Product: Mono/Compilers
+Version: unspecified
+OS: unknown
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: bmaurer@users.sf.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: We do not detect CS0034 in the presence of implicit conversions
+
+MCS incorrectly compiles this code:
+
+public class A {
+	public static implicit operator int (A a)
+	{
+		return 0;
+	}
+
+	public static implicit operator string (A a)
+	{
+		return null;
+	}
+
+	public static void Main ()
+	{
+		A a = new A ();
+		object o = a + a;
+	}
+}
+
+csc gives
+
+t.cs(15,14): error CS0034: Operator '+' is ambiguous on operands of 
+type 'A' and 'A'
+
+------- Additional Comments From bmaurer@users.sf.net  2003-12-23 13:24 -------
+Related:
+
+This should give cs0035
+class A {
+	public static implicit operator double (A a)
+	{
+		return 0;
+	}
+
+	public static implicit operator decimal (A a)
+	{
+		return 0;
+	}
+
+	static void Main()
+	{
+		object o = - new A ();
+	}
+}