[Mono-bugs] [Bug 564088] CS0172 incorrectly reported for conditional expression when implicit conversion is available.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Dec 15 04:29:41 EST 2009


http://bugzilla.novell.com/show_bug.cgi?id=564088

http://bugzilla.novell.com/show_bug.cgi?id=564088#c1


Marek Safar <msafar at novell.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msafar at novell.com

--- Comment #1 from Marek Safar <msafar at novell.com> 2009-12-15 09:29:39 UTC ---
I think this is MS C# compiler bug, the conversion is ambiguous as `x' can be
converted to int (0) and literal 0 can be converted to byte.

There should be no type promotion to avoid this like this

var x = true ? x : 0;  // csc compiles this as int which I think is wrong as
your intentions are unclear, did you want to define int or byte ?

To write it correctly (as C# standard defines) use

byte a = true ? x : (byte) 0;

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list