[Mono-bugs] [Bug 80026][Wis] New - Operator override not applied to null
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Fri Nov 24 03:37:19 EST 2006
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by charlie at nunit.com.
http://bugzilla.ximian.com/show_bug.cgi?id=80026
--- shadow/80026 2006-11-24 03:37:19.000000000 -0500
+++ shadow/80026.tmp.9915 2006-11-24 03:37:19.000000000 -0500
@@ -0,0 +1,41 @@
+Bug#: 80026
+Product: Mono: Compilers
+Version: 1.2
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: C#
+AssignedTo: rharinath at novell.com
+ReportedBy: charlie at nunit.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Operator override not applied to null
+
+An operator override defined on a user type does not apply when the
+argument is explicitly null.
+
+Example:
+
+In NUnitLite, the Constraint type overrides operator ! as follows:
+
+public static Constraint operator !(Constraint m)
+{
+ return new NotConstraint(m == null ? new EqualConstraint(null) : m);
+}
+
+The following fails to compile...
+
+Assert.That( 42, !(Constraint)null );
+
+The following workaround compiles successfully
+
+Constraint x = null;
+Assert.That( 42, !x );
+
+This is a bit of an odd case, but it does compile under the microsoft
+compilers.
More information about the mono-bugs
mailing list