[IronPython] out parameters

Andrzej Krzywda andrzej.krzywda at resolversystems.com
Mon May 15 15:53:02 CEST 2006


Hi all,

Having the following piece of C# code (note the ignore parameter):  

    public class C
    {
        public static int M(out int i, out int j, out int k, bool ignore)
        {
            i = 20;
            j = 30;
            k = 40;
            return 10;
        }
    }


we call it from IronPython Beta 6:

i = C.M(True)

and we get :

        Unhandled Exception: generate:  type: System.DBNull
   at IronPython.Compiler.CodeGen.EmitRawConstant(Object value)
   at 
IronPython.Compiler.ReflectOptimizer.MultiCallGenerator.EmitDefaultValue(I
nt32 param, MethodTracker method)
   at 
IronPython.Compiler.ReflectOptimizer.MultiCallGenerator.EmitParameter(Meth
odTracker method, ParameterInfo pi, Int32 param)
   at 
IronPython.Compiler.ReflectOptimizer.MultiCallGenerator.EmitParameters(Met
hodTracker method, ParameterInfo[] pis, Int32 paramOffset)
   at 
IronPython.Compiler.ReflectOptimizer.MultiCallGenerator.EmitFinalCall(Meth
odTracker method)
   at IronPython.Compiler.ReflectOptimizer.MultiCallGenerator.Walk(Int32 
param,
ParamTreeNode node)
   at IronPython.Compiler.ParamTree.WalkWorker(IParamWalker callback, 
ParamTreeN
ode curNode, Int32 depth)
   at IronPython.Compiler.ParamTree.Walk(IParamWalker callback)
   at IronPython.Compiler.ReflectOptimizer.GenerateTargetMethod(TypeGen 
tg, Stri
ng name, FunctionType funcType, MethodTracker[] methods, Int32 argCnt, 
Boolean p
aramsMethod)
   at IronPython.Compiler.ReflectOptimizer.GenerateAllTargets(TypeGen 
tg, String
 name, MethodTracker[] methods, FunctionType funcType)
   at IronPython.Compiler.ReflectOptimizer.MakeFunction(BuiltinFunction rm)
   at IronPython.Runtime.ReflectedMethodBase.OptimizeMethod()
   at IronPython.Runtime.ReflectedMethodBase.TryOptimizedCall(Object[] 
args, Obj
ect& ret)
   at IronPython.Runtime.ReflectedMethodBase.TryCallWorker(Object[] 
args, Object
& ret)
   at IronPython.Runtime.ReflectedMethodBase.Call(Object[] args)
   at IronPython.Runtime.ReflectedMethodBase.Call(ICallerContext 
context, Object
[] args)
   at IronPython.Runtime.ReflectedMethodBase.Call(ICallerContext 
context, Object
 arg0)
   at IronPython.Runtime.Ops.CallWithContext(ICallerContext context, 
Object func
, Object arg0)
   at __main__.testOut$f0(FunctionEnvironment16Dictionary $env, Object 
self) in
C:\IronPythonTest.py:line 21
   at IronPython.Runtime.Function1.Call(Object arg0)
   at IronPython.Runtime.Ops.Call(Object func, Object arg0)
   at IronPython.Runtime.Method.Call()
   at IronPython.Runtime.Ops.CallWithContext(ICallerContext context, 
Object func
)

However, if we change the order of the parameters so that "bool ignore" 
is the first one, it works !%$£"#@&&*

We think this worked in beta 4, as we only caught this when moving our 
code to the beta 6 IronPython.

See the following email for previous discussions on the subject :

    
http://lists.ironpython.com/pipermail/users-ironpython.com/2005-May/000644.html

Andrzej Krzywda
Michael Foord
http://www.resolversystems.com



More information about the Ironpython-users mailing list