[Mono-bugs] [Bug 58126][Nor] New - Casting to a delegate and passing array parameters

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 6 May 2004 07:29:20 -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 dag_trygve@hotmail.com.

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

--- shadow/58126	2004-05-06 07:29:20.000000000 -0400
+++ shadow/58126.tmp.8866	2004-05-06 07:29:20.000000000 -0400
@@ -0,0 +1,67 @@
+Bug#: 58126
+Product: Mono: Compilers
+Version: unspecified
+OS: Red Hat 8.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: dag_trygve@hotmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Casting to a delegate and passing array parameters
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+Compiler fails compiling the code below, it compiles fine from Visual
+Studio. Workaround provided in commented code (split line in two).
+Problem seems to occur when passing an array to the delegate.
+
+Steps to reproduce the problem:
+
+using System;
+using System.Collections;
+
+class Test
+{
+    public delegate int TestDelegate(int a, int[] b);
+
+    public static void Main(string[] argv)
+    {
+        SortedList ls = new SortedList();
+        ls.Add( "test", new TestDelegate( TestMethod ) );
+        int b = ((TestDelegate)ls["test"])( 1, new int[] {2,3,4} );
+        //TestDelegate del = (TestDelegate)ls["test"];
+        //int b = del( 1, new int[] {2,3,4} );
+        Console.WriteLine( b.ToString() );
+    }
+
+    public static int TestMethod(int a, int[] b)
+    {
+        int res = a;
+        if (b!=null) foreach (int n in b) res += n;
+        return res;
+    }
+}
+
+
+Actual Results:
+syntax error, got token `COMMA', expecting AS IS OPEN_BRACKET CLOSE_PARENS
+PLUS MINUS OP_LT OP_GT BITWISE_AND BITWISE_OR STAR PERCENT DIV CARRET
+INTERR OP_SHIFT_LEFT OP_SHIFT_RIGHT OP_LE OP_GE OP_EQ OP_NE OP_AND OP_OR
+bug2.cs(12) error CS1002: Expecting `;'
+
+
+Expected Results:
+No errors
+
+How often does this happen? 
+Every time
+
+Additional Information: