[Mono-bugs] [Bug 31420][Nor] New - expressions with enum types
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
28 Sep 2002 10:09:02 -0000
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 lupus@ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=31420
--- shadow/31420 Sat Sep 28 06:09:02 2002
+++ shadow/31420.tmp.1157 Sat Sep 28 06:09:02 2002
@@ -0,0 +1,45 @@
+Bug#: 31420
+Product: Mono/MCS
+Version: unspecified
+OS: other
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: lupus@ximian.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: expressions with enum types
+
+The C# spec re the + and - operators with enum types is very weird
+and mcs doesn't follow the spec (14.7.4 and 14.7.5): I didn't check other
+operators, but there may be similar issues.
+The following sample does compile with csc, but not with mcs.
+I commented out some expressions that must make the compiler output an error.
+It is weird, because the spec defines different default implicit operators
+for addition and subtraction, so in some expressions using - is allowed,
+but not +.
+enum E {
+ ZERO,
+ ONE,
+ TWO = ONE + ONE
+}
+class T {
+ static void Main () {
+ E a = E.ONE;
+ E b = E.ONE;
+// bool val = (a + b) < 10;
+ bool val2 = (a - b) < 10;
+// E c = a - b;
+ int c2 = a - b;
+// int c3 = a + b;
+// int c3 = a + 1;
+ E c3 = a + 1;
+// E c4 = a + b;
+ }
+}