[Mono-bugs] [Bug 68955][Nor] New - delegate with params array not handled correctly
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Sat, 30 Oct 2004 17:00:49 -0400 (EDT)
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 vgough@pobox.com.
http://bugzilla.ximian.com/show_bug.cgi?id=68955
--- shadow/68955 2004-10-30 17:00:49.000000000 -0400
+++ shadow/68955.tmp.21093 2004-10-30 17:00:49.000000000 -0400
@@ -0,0 +1,51 @@
+Bug#: 68955
+Product: Mono: Compilers
+Version: unspecified
+OS:
+OS Details: Suse 9.1
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: vgough@pobox.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: delegate with params array not handled correctly
+
+Please fill in this template when reporting a bug, unless you know what
+you are doing.
+Description of Problem:
+
+If you define a delegate with variable number of parameters:
+
+ delete void Foo( string format, params object[] args );
+
+Then if you try and call it with no additional arguments, the compiler
+fails:
+ void Handler( string format, params object[] args ) {}
+
+ Foo foo = new Foo( Handler );
+ foo( "hello world" );
+
+error CS1593: Delegate 'Foo' does not take '1' arguments
+
+If you try and call it with multiple arguments it also fails:
+
+ int i = 10;
+ foo( "i = %i", i );
+
+error CS1594: Delegate 'Foo' has some invalid arguments.
+error CS1503: Argument 1: Cannot convert from 'int' to 'object[]'
+
+I was following examples of C# found on the net (one of which dates back
+to 2002), which lead me to believe this is supposed to work.
+
+
+Steps to reproduce the problem:
+1. define delegate taking multiple parameters (using 'params' keyword)
+2. attempt to call delegate using any number of parameters..
+3. see mcs barf