[Mono-bugs] [Bug 82528][Nor] Changed - Return type of delegate is not checked

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sat Sep 1 04:32:52 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 gert.driesen at pandora.be.

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

--- shadow/82528	2007-08-22 11:52:57.000000000 -0400
+++ shadow/82528.tmp.14211	2007-09-01 04:32:52.000000000 -0400
@@ -11,13 +11,13 @@
 AssignedTo: mono-bugs at ximian.com                            
 ReportedBy: amcharg at gmail.com               
 QAContact: mono-bugs at ximian.com
 TargetMilestone: ---
 URL: 
 Cc: 
-Summary: Segfault when Type.IsInstanceOfType is used on result from float.Parse when invoked as a delegate returning Object.
+Summary: Return type of delegate is not checked
 
 Description of Problem:
 
 Mono 1.2.4 seems behave improperly when float.Parse is invoked as a
 delegate returning an object.
 
@@ -85,6 +85,59 @@
 The above does not compile with csc, I get the following:
 
 error CS0407: 'float float.Parse(string)' has the wrong return type
 
 Also, if I compile with gmcs and then run with .Net I also do not get
 any output.
+
+------- Additional Comments From gert.driesen at pandora.be  2007-09-01 04:32 -------
+Apparently, (g)mcs does not (always?) check the return type of a 
+delegate.
+
+To reproduce, compile the following code:
+
+using System;
+using System.Globalization;
+
+delegate object ParseFun (string text, IFormatProvider provider);
+
+class Program
+{
+	static void Main ()
+	{
+		ParseFun runner = new ParseFun (ParseA);
+		runner ("a", CultureInfo.InvariantCulture);
+
+		runner = new ParseFun (ParseB);
+		runner ("b", CultureInfo.InvariantCulture);
+	}
+
+	static bool ParseA (string text, IFormatProvider provider)
+	{
+		return false;
+	}
+
+	static void ParseB (string text, IFormatProvider provider)
+	{
+	}
+}
+
+Actual result:
+
+Successful compilation.
+
+Expected result:
+
+mcs (C# 1.0):
+test.cs(10,35): error CS0123: Method 'Program.ParseA(string, 
+System.IFormatProvider)' does not match delegate 'object ParseFun
+(string, System.IFormatProvider)'
+test.cs(13,26): error CS0123: Method 'Program.ParseB(string, 
+System.IFormatProvider)' does not match delegate 'object ParseFun
+(string, System.IFormatProvider)'
+
+gmcs (C# 2.0):
+test.cs(10,21): error CS0407: 'bool Program.ParseA(string, 
+System.IFormatProvider)' has the wrong return type
+test.cs(13,12): error CS0407: 'void Program.ParseB(string, 
+System.IFormatProvider)' has the wrong return type
+


More information about the mono-bugs mailing list