[Mono-bugs] [Bug 82434][Nor] New - Compiler and runtime claim that 1 is an int and 1 is a decimal

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Aug 14 04:20:23 EDT 2007


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 chuck.esterbrook at gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=82434

--- shadow/82434	2007-08-14 04:20:23.000000000 -0400
+++ shadow/82434.tmp.30112	2007-08-14 04:20:23.000000000 -0400
@@ -0,0 +1,66 @@
+Bug#: 82434
+Product: Mono: Compilers
+Version: 1.2
+OS: Mac OS X 10.3
+OS Details: Mac OS X 10.4
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: Chuck.Esterbrook at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Compiler and runtime claim that 1 is an int and 1 is a decimal
+
+Description of Problem:
+
+I had an error with some C# code brought over from .NET which I boiled down to:
+
+using System;
+class Test {
+	static public void Main() {
+		Console.WriteLine("1 is int == {0}", 1 is int);
+		Console.WriteLine("1 is decimal == {0}", 1 is decimal);
+	}
+}
+
+The C# compiler for .NET 2.0 says:
+decimal.cs(6,40): warning CS0183: The given expression is always of the
+provided ('int') type
+decimal.cs(7,44): warning CS0184: The given expression is never of the
+provided ('decimal') type
+
+I agree since 'int' and 'decimal' are structs and a value like 1 cannot
+possibly belong to both.
+
+gmcs for Novell Mono says:
+decimal.cs(6,56): warning CS0183: The given expression is always of the
+provided (`int') type
+decimal.cs(7,60): warning CS0183: The given expression is always of the
+provided (`decimal') type
+
+Which I disagree. If 1 is an int, it can't be a decimal (although there may
+be an implicit conversion, but I don't think 'is' tests for implicit
+conversions).
+
+The runtime behavior of both platforms matches what the respective compiler
+messages say. So .NET prints "True" and "False" while Mono prints "True"
+and "True".
+
+Actual Results:
+
+True
+True
+
+Expected Results:
+
+True
+False
+
+How often does this happen? 
+
+Always.


More information about the mono-bugs mailing list