[Mono-bugs] [Bug 79566][Nor] Changed - as keyword doesn't work with nullable value types

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Oct 3 09:51:05 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 pedro at sobota.net.

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

--- shadow/79566	2006-10-03 09:47:26.000000000 -0400
+++ shadow/79566.tmp.18849	2006-10-03 09:51:05.000000000 -0400
@@ -2,13 +2,13 @@
 Product: Mono: Compilers
 Version: unspecified
 OS: All
 OS Details: 
 Status: NEW   
 Resolution: 
-Severity: 
+Severity: Unknown
 Priority: Normal
 Component: C#
 AssignedTo: rharinath at novell.com                            
 ReportedBy: pedro at sobota.net               
 QAContact: mono-bugs at ximian.com
 TargetMilestone: ---
@@ -23,6 +23,45 @@
         Console.Write(2 as int?);
     }
 }
 
 CS0077: The as operator must be used with a
 reference type ('int?' is a value type).
+
+------- Additional Comments From pedro at sobota.net  2006-10-03 09:51 -------
+Pedro Sobota wrote:
+> Hi,
+>
+> It seems in Mono, nullables are seen as value types, like the values
+> they contain. This is different from the .Net Framework, for example,
+> this code compiles and works on .Net, but not on Mono:
+>
+> using System;
+>
+> class Global {
+>     static void Main() {
+>         Console.Write(2 as int?);
+>     }
+> }
+>
+> On Mono the result is error CS0077: The as operator must be used with a
+> reference type ('int?' is a value type).
+>
+> Is this intended, or a bug?
+>
+> Pedro 
+
+Steve Deobald escreveu:
+> > Nullables are value types. It seems the .Microsoft NET Framework
+> > permits this as an exceptional case for usages of the 'as' keyword
+> > with Nullable<T> on the right. It would seem Mono should do the same
+> > if it currently does not.
+> >
+> > -Steve
+
+Pedro Sobota wrote:
+> > You are right. In this case, I don't get why csc lets the use of 'as' 
+> > with a nullable value type, if a conventional value type is not 
+> > supported. Should gmcs act like csc, or be coherent?
+
+Robert Jordan:
+> Please file a bug.


More information about the mono-bugs mailing list