Bugzilla – Bug 323222
[GMCS] Inference of generic parameters fails
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by dmitchell@logos.com 2007-01-16 18:56:36 MST ---- Description of Problem: The attached file has two functions. The first does nothing, but takes some generic parameters. The second function calls the first but does not explicitly provide the generic parameters. Microsoft's C# compiler correclty infers the parameter values, but gmcs reports error CS0411 Steps to reproduce the problem: 1. Download the attached source file 2. Attempt to compile it with the /target:library option Actual Results: With gmcs under Mono 1.2.2.1 - The second function results in a CS0411 error. With csc: Compilation completes successfully Expected Results: Compilation should complete successfully How often does this happen? Always ---- Additional Comments From dmitchell@logos.com 2007-01-16 18:57:23 MST ---- Created an attachment (id=171286) This source file will trigger the described bug ---- Additional Comments From dmitchell@logos.com 2007-01-23 20:40:13 MST ---- The problem seems to be in the file mcs/gmcs/generic.cs in the function static bool InferTypeArguments (Type[] param_types, Type[] arg_types, Type[] infered_types). This function calls InferType for each parameter on the method, and if the call fails--for any reason--the call to InferTypeArguments will fail. The problem with this is that InferType will fail if it unable to infer all of the generic parameters, even if subsequent method parameters might be able to correctly infer some of the missing parameters. I hope to have a patch soon. ---- Additional Comments From dmitchell@logos.com 2007-01-23 21:24:40 MST ---- Created an attachment (id=171287) This will fix the described bug ---- Additional Comments From dmitchell@logos.com 2007-01-23 21:26:56 MST ---- I've now attached a patch that will fix the bug that is described here. However, the scope of my changes was very narrow, and I suspect that other generic parameter inference paths may be similarly affected. It might be a good idea to check this out sometime. ---- Additional Comments From dmitchell@logos.com 2007-01-25 12:45:24 MST ---- Sorry...I just edited the wrong bug... ---- Additional Comments From dmitchell@logos.com 2007-01-25 12:46:23 MST ---- Nevermind the last comment...I'm still getting used to how Bugzilla jumps between bugs when you edit one. ---- Additional Comments From rharinath@novell.com 2007-01-28 15:15:40 MST ---- Should be fixed in SVN r71817. Thanks for tracking down the reason for the bug. I've committed a different patch that also fixes an erroneously classified testcase. Imported an attachment (id=171286) Imported an attachment (id=171287) Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>Also confirmed on Mac OS X</cf_op_sys_details> Unknown operating system unknown. Setting to default OS "Other".