[Mono-dev] Bug: Generic Function that returns a Delegate from \-Expression
Miguel de Icaza
miguel at novell.com
Wed Aug 20 16:24:23 EDT 2008
Hello Simon,
Thanks for the report, could you please file the bug report in:
www.mono-project.com/Bugs
I tried it with Mono 2.0, and got a different error:
Unhandled Exception: System.Exception: Trying to emit a local from a
different ILGenerator.
at System.Reflection.Emit.ILGenerator.Emit (OpCode opcode,
System.Reflection.Emit.LocalBuilder local) [0x00000]
at Mono.CSharp.LocalTemporary.Emit (Mono.CSharp.EmitContext ec)
[0x00000]
at Mono.CSharp.FieldExpr.EmitAssign (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression source, Boolean leave_copy, Boolean
prepare_for_load) [0x00000]
at Mono.CSharp.Assign.Emit (Mono.CSharp.EmitContext ec, Boolean
is_statement) [0x00000]
at Mono.CSharp.Assign.EmitStatement (Mono.CSharp.EmitContext ec)
[0x00000]
at Mono.CSharp.AnonymousMethodStorey.EmitHoistedFieldsInitialization
(Mono.CSharp.EmitContext ec) [0x00000]
at Mono.CSharp.AnonymousMethodStorey.EmitHoistedVariables
(Mono.CSharp.EmitContext ec) [0x00000]
at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec)
[0x00000]
at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec)
[0x00000]
at Mono.CSharp.EmitContext.EmitResolvedTopBlock
(Mono.CSharp.ToplevelBlock block, Boolean unreachable) [0x00000]
at Mono.CSharp.EmitContext.EmitTopBlock (IMethodData md,
Mono.CSharp.ToplevelBlock block) [0x00000]
> Hello List,
> I experienced a bug with mono 1.9.1 x64/Linux. Compilation fails (it works
> with MS csc 3.5.21022.8). Source and gmcs output is attached.
>
>
> $ ./gmcs --version
> Mono C# compiler version 1.9.1.0
>
> $ gcc --version
> gcc (GCC) 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
>
> Regards,
> Simon Hengel
> plain text document attachment (curry_bug.cs)
> using System;
> using System.Linq;
> using System.Collections.Generic;
>
> static class CurryBug
> { // curry for function of arity 3
> //
> // this compiles
> public static Func<int,Func<int, Func<int,int>>>
> curry_for_int_func (this Func<int,int,int,int> f)
> {
> return arg1 => arg2 => arg3 => f(arg1 , arg2 , arg3);
> }
>
> // but his does not
> static Func<A,Func<B,Func<C,D>>> curry<A,B,C,D> (this Func<A,B,C,D> f)
> {
> return arg1 => arg2 => arg3 => f(arg1, arg2, arg3);
> }
>
> static void Main ()
> {
> Func<int,int,int,int> plus = (x, y, z) => x + y + z;
>
> Console.WriteLine(plus.curry()(7)(23)(47));
> }
> }
> plain text document attachment (curry_bug.cs.stderr_and_stdout)
> Internal compiler error at curry_bug.cs(16,42):: exception caught while emitting MethodBuilder [CurryBug::curry]
>
> Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
> at Mono.CSharp.ConstructedType..ctor (System.Type t, Mono.CSharp.TypeParameter[] type_params, Location l) [0x00000]
> at Mono.CSharp.TypeContainer.DoResolveType () [0x00000]
> at Mono.CSharp.TypeContainer.ResolveType () [0x00000]
> at Mono.CSharp.TypeContainer.ResolveType () [0x00000]
> at Mono.CSharp.RootScopeInfo.LinkScopes () [0x00000]
> at Mono.CSharp.ToplevelBlock.CompleteContexts (Mono.CSharp.EmitContext ec) [0x00000]
> at Mono.CSharp.EmitContext.ResolveTopBlock (Mono.CSharp.EmitContext anonymous_method_host, Mono.CSharp.ToplevelBlock block, Mono.CSharp.Parameters ip, IMethodData md, System.Boolean& unreachable) [0x00000]
> at Mono.CSharp.EmitContext.EmitTopBlock (IMethodData md, Mono.CSharp.ToplevelBlock block) [0x00000]
> at Mono.CSharp.MethodData.Emit (Mono.CSharp.DeclSpace parent) [0x00000]
> at Mono.CSharp.Method.Emit () [0x00000]
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
More information about the Mono-devel-list
mailing list