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


           Summary: gmcs fails to compile nullable user defined unary
                    operators
           Product: Mono: Compilers
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]
         QAContact: [email protected]
          Found By: ---


The following test case compiles with csc and should print OK:

>>>>>>>>>>>>>>>>>>>>
using System;

struct Foo {

        public int Value;

        public Foo (int value)
        {
                this.Value = value;
        }

        public static Foo operator - (Foo? f)
        {
                if (f.HasValue)
                        return new Foo (-f.Value.Value);

                return new Foo (42);
        }
}

struct Bar {

        public int Value;

        public Bar (int value)
        {
                this.Value = value;
        }

        public static Bar? operator - (Bar? b)
        {
                if (b.HasValue)
                        return new Bar (-b.Value.Value);

                return b;
        }
}

class Test {

        static Foo NegateFoo (Foo f)
        {
                return -f;
        }

        static Foo NegateFooNullable (Foo? f)
        {
                return -f;
        }

        static Bar? NegateBarNullable (Bar? b)
        {
                return -b;
        }

        static Bar? NegateBar (Bar b)
        {
                return -b;
        }

        static int Main ()
        {
                if (NegateFooNullable (null).Value != 42)
                        return 1;

                if (NegateFoo (new Foo (2)).Value != -2)
                        return 2;

                if (NegateBarNullable (null) != null)
                        return 3;

                if (NegateBar (new Bar (2)).Value.Value != -2)
                        return 4;

                Console.WriteLine ("OK");
                return 0;
        }
}
<<<<<<<<<<<<<<<<<


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to