[Mono-bugs] [Bug 54928][Nor] Changed - implicit operator cannot convert from struct to decimal

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue May 24 19:07:28 EDT 2005


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 duncan at ximian.com.

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

--- shadow/54928	2005-04-16 17:01:04.000000000 -0400
+++ shadow/54928.tmp.19028	2005-05-24 19:07:28.000000000 -0400
@@ -1,12 +1,12 @@
 Bug#: 54928
 Product: Mono: Compilers
 Version: unspecified
 OS: unknown
 OS Details: Win2K
-Status: NEW   
+Status: ASSIGNED   
 Resolution: 
 Severity: Unknown
 Priority: Normal
 Component: C#
 AssignedTo: rharinath at novell.com                            
 ReportedBy: yoonkit at yahoo.com               
@@ -96,6 +96,60 @@
 performed.
 
 So, we are missing the "if TX is not T" clause. I think the "S is not 
 SX" is already covered because the source always has to be either S 
 or a parent class of S. I am pretty sure we already cover this 
 situation. However, TX -> T could be *any* implict conversion.
+
+------- Additional Comments From duncan at ximian.com  2005-05-24 19:07 -------
+I think the problem is not with any of the FindMostSpecific*,
+FindMostEncompossing* methods. The problem is that, in
+GetConversionOperators, we're not returning only user-defined operators.
+
+Given this test case:
+public struct ObjectID {
+	long l;
+
+	public ObjectID (long l)
+	{
+		this.l = l;
+	}
+
+	public static implicit operator long (ObjectID p)
+	{
+		return p.l;
+	}
+
+	public static implicit operator ObjectID (long l)
+	{
+		return new ObjectID (l);
+	}
+
+	static void Main ()
+	{
+		ObjectID x = new ObjectID (0);
+		decimal y = x;
+	}
+}
+
+Here's the output I get (plus some printfs):
+polysemy:~/bugs $ mcs 54928.cs
+UserDefinedConversion
+S: ObjectID -> T: System.Decimal
+U consists of:
+op_Implicit from System.Int64 to ObjectID
+op_Implicit from ObjectID to System.Int64
+op_Implicit from System.Byte to System.Decimal
+op_Implicit from System.SByte to System.Decimal
+op_Implicit from System.Int16 to System.Decimal
+op_Implicit from System.UInt16 to System.Decimal
+op_Implicit from System.Char to System.Decimal
+op_Implicit from System.Int32 to System.Decimal
+op_Implicit from System.UInt32 to System.Decimal
+op_Implicit from System.Int64 to System.Decimal
+op_Implicit from System.UInt64 to System.Decimal
+Sx: ObjectID | Tx: System.Decimal
+54928.cs(26) error CS0029: Cannot convert implicitly from `ObjectID'
+to `decimal'
+
+I think U should include only the first 2 conversion operators, in
+which case, Tx becomes "System.Int64", and not "System.Decimal".


More information about the mono-bugs mailing list