[Mono-bugs] [Bug 395845] New: gmcs fails to compile nullable user defined unary operators
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Fri May 30 10:08:29 EDT 2008
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: msafar at novell.com
ReportedBy: jbevain at novell.com
QAContact: mono-bugs at lists.ximian.com
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.
More information about the mono-bugs
mailing list