[Mono-bugs] [Bug 348255] New: Bug in turnary operator + nullable types

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Dec 12 20:25:51 EST 2007


https://bugzilla.novell.com/show_bug.cgi?id=348255


           Summary: Bug in turnary operator + nullable types
           Product: Mono: Compilers
           Version: 1.2.5
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at ximian.com
        ReportedBy: alan.mcgovern at gmail.com
         QAContact: mono-bugs at ximian.com
          Found By: ---


The following code doesn't compile, it gives this error:

Error:
[Task:File=/home/alan/test/test/Main.cs, Line=13, Column=40, Type=Error,
Priority=Normal, Description=Type of conditional expression cannot be
determined because there is no implicit conversion between `null' and
`Test.Album'(CS0173)]

Code:

using System;
using System.Runtime.InteropServices;

namespace Test
{
        public struct Album
        {       
                public int a=0;
                public Album? Next
                {
                        get { return a == 1 ? null : new Album(); }
                }
        }

        public class MainClass
        {
                public static void Main(string[] args)
                {

                }
        }
}


However if you change the getter to do this, it does compile:
get
{
        if(a == 1)
                return null;
        else
                return new Album();
}


-- 
Configure bugmail: https://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