Bug 313442 (MONO52492) - [PATCH] We do not detect CS0034 in the presence of implicit conversions
Summary: [PATCH] We do not detect CS0034 in the presence of implicit conversions
Status: RESOLVED FIXED
Alias: MONO52492
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-23 20:20 UTC by Ben Maurer
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
proposed fix (1.67 KB, patch)
2005-08-23 12:58 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 18:22:42 UTC


---- Reported by bmaurer@users.sf.net 2003-12-23 13:20:18 MST ----

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:39 MST ----

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 ();
	}
}



---- Additional Comments From bmaurer@users.sf.net 2004-03-13 00:48:20 MST ----

`The overload resolution rules of Section 7.4.2 are applied to the set
of candidate operators to select the best operator with respect to the
argument list (x, y), and this operator becomes the result of the
overload resolution process. If overload resolution fails to select a
single best operator, a compile-time error occurs.'

	 
7.2.4 Binary operator overload resolution




---- Additional Comments From miguel@ximian.com 2004-04-11 00:41:08 MST ----

This bug requires a large change to the way the compiler handles
operators, not something we will do for 1.0, something for later.

Am setting to wishlist given that we cant fix it now.



---- Additional Comments From duncan@ximian.com 2005-05-26 14:08:47 MST ----

*** https://bugzilla.novell.com/show_bug.cgi?id=MONO73709 has been marked as a duplicate of this bug. ***



---- Additional Comments From atsushi@ximian.com 2005-08-23 05:58:22 MST ----

Created an attachment (id=165381)
proposed fix




---- Additional Comments From miguel@ximian.com 2005-08-23 16:01:18 MST ----

approved, please apply + add test



---- Additional Comments From atsushi@ximian.com 2005-08-23 16:31:34 MST ----

applied (r48759).

Imported an attachment (id=165381)

Unknown operating system unknown. Setting to default OS "Other".