[Mono-bugs] [Bug 417870] New: [gmcs] InternalErrorException with Expression Templates

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Aug 17 14:09:12 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=417870


           Summary: [gmcs] InternalErrorException with Expression Templates
           Product: Mono: Compilers
           Version: SVN
          Platform: x86-64
        OS/Version: openSUSE 11.0
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jpryor at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


gmcs generates an InternalErrorException when processing a file making use of
Expression<T>.

Save the following source:

  using System;
  using System.Linq.Expressions;
  using Mono.Rocks;

  namespace Mono.Rocks {

    public static class Lambda {

      public static Action<T1, T2>
        Func<T1, T2> (Action<T1, T2> action)
        {
          return action;
        }

      public static Func<T1, T2, TResult>
        Func<T1, T2, TResult> (Func<T1, T2, TResult> func)
        {
          return func;
        }

      public static Expression<Action<T1, T2>>
        Expression<T1, T2> (Expression<Action<T1, T2>> expr)
        {
          return expr;
        }

      public static Expression<Func<T1, T2, TResult>>
        Expression<T1, T2, TResult> (Expression<Func<T1, T2, TResult>> expr)
        {
          return expr;
        }
    }
  }

  class Test {
    static void Assert<T> (T expected, T actual)
    {
      if (!expected.Equals (actual))
        throw new InvalidOperationException ();
    }

    public static void Main ()
    {
      Assert (typeof(Action<int,int>), 
          Lambda.Func((int x, int y) => {}).GetType());
      Assert (typeof(Func<int,int,int>), 
          Lambda.Func((int x, int y) => x+y).GetType());
      Assert (typeof(Expression<Action<int,int>>), 
          Lambda.Expression((int x, int y) => {}).GetType());
      Assert (typeof(Expression<Func<int,int,int>>), 
          Lambda.Expression ((int x, int y) => x+y).GetType());
    }
  }

Compile it:

  gmcs e.cs

Expected output:

Nothing.

Actual output:

Exception caught by the compiler while compiling:
   Block that caused the problem begin at: e.cs(42,24):
                     Block being compiled: [e.cs(43,5):,e.cs(52,5):]
Mono.CSharp.InternalErrorException: e.cs(49,44):
Internal compiler error at e.cs(42,24):: exception caught while emitting
MethodBuilder [Test::Main]

Unhandled Exception: Mono.CSharp.InternalErrorException: e.cs(49,44): --->
System.ArgumentOutOfRangeException: Index is less than 0 or more than or equal
to the list count.
Parameter name: index
0
  at System.Collections.ArrayList.ThrowNewArgumentOutOfRangeException
(System.String name, System.Object actual, System.String message) [0x00000] 
  at System.Collections.ArrayList.get_Item (Int32 index) [0x00000] 
  at Mono.CSharp.ToplevelBlock.CreateExpressionTree (Mono.CSharp.EmitContext
ec) [0x00000] 
  at Mono.CSharp.LambdaExpression.CreateExpressionTree (Mono.CSharp.EmitContext
ec, System.Type delegate_type) [0x00000] 
  at Mono.CSharp.AnonymousMethodExpression.Compatible (Mono.CSharp.EmitContext
ec, System.Type type) [0x00000] 
  --- End of inner exception stack trace ---
  at Mono.CSharp.AnonymousMethodExpression.Compatible (Mono.CSharp.EmitContext
ec, System.Type type) [0x00000] 
  at Mono.CSharp.Convert.ImplicitConversionStandard (Mono.CSharp.EmitContext
ec, Mono.CSharp.Expression expr, System.Type target_type, Location loc, Boolean
explicit_cast) [0x00000] 
  at Mono.CSharp.Convert.ImplicitConversionStandard (Mono.CSharp.EmitContext
ec, Mono.CSharp.Expression expr, System.Type target_type, Location loc)
[0x00000] 
  at Mono.CSharp.Convert.ImplicitConversion (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression expr, System.Type target_type, Location loc) [0x00000] 
  at Mono.CSharp.MethodGroupExpr.VerifyArgumentsCompat (Mono.CSharp.EmitContext
ec, System.Collections.ArrayList& arguments, Int32 arg_count,
System.Reflection.MethodBase method, Boolean chose_params_expanded, Boolean
may_fail, Location loc) [0x00000] 
  at Mono.CSharp.MethodGroupExpr.OverloadResolve (Mono.CSharp.EmitContext ec,
System.Collections.ArrayList& Arguments, Boolean may_fail, Location loc)
[0x00000] 
  at Mono.CSharp.Invocation.DoResolveOverload (Mono.CSharp.EmitContext ec)
[0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Argument.Resolve (Mono.CSharp.EmitContext ec, Location loc)
[0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.EmitContext
ec) [0x00000] 
  at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.EmitContext ec)
[0x00000] 
  at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ExplicitBlock.Resolve (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]


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list