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


           Summary: gmcs fails to compile nullable user defined binary
                    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: ---


Test case that compiles with csc:

<<<<<<<<<<<
using System;

struct Foo {

        public int Value;

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

        public static Foo operator + (Foo? a, Foo? b)
        {
                if (a.HasValue && b.HasValue)
                        return new Foo (a.Value.Value + b.Value.Value);

                return new Foo (42);
        }
}

struct Bar {

        public int Value;

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

        public static Bar? operator + (Bar? a, Bar? b)
        {
                if (a.HasValue && b.HasValue)
                        return new Bar (a.Value.Value + b.Value.Value);

                return null;
        }
}

class Test {

        static Foo AddFoo (Foo a, Foo b)
        {
                return a + b;
        }

        static Foo AddFooNullable (Foo? a, Foo? b)
        {
                return a + b;
        }

        static Bar? AddBarNullable (Bar? a, Bar? b)
        {
                return a + b;
        }

        static Bar? AddBar (Bar a, Bar b)
        {
                return a + b;
        }

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

                if (AddFoo (new Foo (2), new Foo (2)).Value != 4)
                        return 2;

                if (AddBarNullable (null, null) != null)
                        return 3;

                if (AddBar (new Bar (2), new Bar (2)).Value.Value != 4)
                        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