[Mono-bugs] [Bug 78964][Nor] New - '??' operator causes wrong CS0019 for implicit casts in first operand

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Jul 28 03:58:37 EDT 2006


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 moritz.kroll at gmx.de.

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

--- shadow/78964	2006-07-28 03:58:37.000000000 -0400
+++ shadow/78964.tmp.21263	2006-07-28 03:58:37.000000000 -0400
@@ -0,0 +1,57 @@
+Bug#: 78964
+Product: Mono: Compilers
+Version: 1.1
+OS: Windows XP
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: Moritz.Kroll at gmx.de               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: '??' operator causes wrong CS0019 for implicit casts in first operand
+
+Description of Problem:
+The '??' operator doesn't allow an implicit cast for the first operand.
+
+Steps to reproduce the problem:
+Try the following small program:
+
+namespace CS0019Bug
+{
+    class A {}
+    class B : A {}
+
+    class Program
+    {
+        static A aElem;
+        static B bElem;
+
+        static void Main()
+        {
+            A blub = (A) bElem ?? aElem;    // works
+            A blab = bElem ?? aElem;        // doesn't work
+            A blib = aElem ?? bElem;        // works
+        }
+    }
+}
+
+
+Actual Results:
+Compiler error: mono-cs0019-bug.cs(14,36): error CS0019: Operator `??' 
+cannot be applied to operands of type `CS0019Bug.B' and `CS0019Bug.A'
+
+Expected Results:
+Compiler should succeed with three warnings about unused variables.
+
+How often does this happen? 
+Always
+
+Additional Information:
+Tried Mono versions: Mono-1.1.13.8 and Mono-1.1.16.1
+Workaround: Use an explicit cast for the first operand.


More information about the mono-bugs mailing list