Bug 322272 (MONO79566) - as keyword doesn't work with nullable value types
Summary: as keyword doesn't work with nullable value types
Status: RESOLVED MOVED
Alias: MONO79566
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: Other All
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Raja R Harinath
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-03 16:47 UTC by Pedro Sobota
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

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


---- Reported by pedro@sobota.net 2006-10-03 09:47:26 MST ----

Differently from csc, using as with a nullable value type doesn't compile:

class Global {
    static void Main() {
        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@sobota.net 2006-10-03 09:51:05 MST ----

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.



---- Additional Comments From marek.safar@seznam.cz 2006-10-03 10:46:15 MST ----



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


This bug was marked DUPLICATE in the database it was moved from.
    Changing resolution to "MOVED"