[Mono-bugs] [Bug 44468][Nor] New - user-defined implicit conversions with params fails
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Tue, 10 Jun 2003 23:00:54 -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 timsuth@ihug.co.nz.
http://bugzilla.ximian.com/show_bug.cgi?id=44468
--- shadow/44468 Tue Jun 10 23:00:54 2003
+++ shadow/44468.tmp.12401 Tue Jun 10 23:00:54 2003
@@ -0,0 +1,48 @@
+Bug#: 44468
+Product: Mono/MCS
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: timsuth@ihug.co.nz
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: user-defined implicit conversions with params fails
+
+For the following code, mcs (0.23.0.0, debianplanet package on woody)
+gives the error
+ "Problem.cs(17) error CS-0006: Could not find any applicable function for
+ this argument list"
+
+Microsoft's compiler successfully compiles the code.
+
+I have a method with a "params" parameter (variable arguments collected
+into an array), and am then calling it in a way which requires my
+user-defined "implicit" conversion to be done.
+
+class Problem {
+ string somedata;
+
+ public Problem(string somedata) {
+ this.somedata = somedata;
+ }
+ public static implicit operator Problem(int x) {
+ return new Problem("" + x);
+ }
+
+ public static int Multi(int first, params Problem[] rest) {
+ return rest.Length;
+ }
+
+ public static void Main(string[] args) {
+ Problem[] ps = new Problem[] { 1, 2, 3 }; // ok
+ Multi(1, 2, 3, 4); // fails to compile
+ }
+}