Bug 513013

Summary: LINQ query comprehension crash
Product: [Mono] Mono: Compilers Reporter: Not Telling <tmorris>
Component: C#Assignee: Mono Bugs <mono-bugs>
Status: RESOLVED DUPLICATE QA Contact: Mono Bugs <mono-bugs>
Severity: Major    
Priority: P5 - None    
Version: 2.4.x   
Target Milestone: ---   
Hardware: x86-64   
OS: Ubuntu   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Not Telling 2009-06-14 03:55:11 UTC
User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.10) Gecko/2009042513 Ubuntu/8.04 (hardy) Firefox/3.0.10

The following code will crash gmcs 2.4.0.0

using System;

public class M {
  class P<A> {
    public P<B> Select<B>(Func<A, B> f) { return null; }

    public P<B> SelectMany<B>(Func<A, P<B>> f) { return null; }

    public P<C> SelectMany<B, C>(Func<A, P<B>> f, Func<A, B, C> g) { return null; }
  }

  public static void Main(string[] args) {
    P<int> a = null;
    P<int> b = null;
    P<int> c = null;

    P<int> t = a.SelectMany(aa => b.Select(bb => aa + bb));
    P<int> u = from aa in a 
               from bb in b 
               select aa + bb;

    P<int> v = from aa in a 
               from bb in b 
               from cc in c
               select aa + bb;

    // causes gmcs crash
    P<int> w = from aa in a 
               from bb in b 
               from cc in c
               select aa + bb + cc;

  }
}


Reproducible: Always

Steps to Reproduce:
1. Compile the given code with gmcs
Actual Results:  
Compiler crash

Exception caught by the compiler while compiling:
   Block that caused the problem begin at: M.cs(30,21):
                     Block being compiled: [M.cs(30,16):,Internal(1,1):]
System.Exception: Expression Mono.CSharp.ParameterReference did not set its type after Resolve
called from: Mono.CSharp.ParameterReference
Exception caught by the compiler while compiling:
   Block that caused the problem begin at: M.cs(13,22):
                     Block being compiled: [M.cs(28,5):,M.cs(31,35):]
System.Exception: Expression Mono.CSharp.ParameterReference did not set its type after Resolve
called from: Mono.CSharp.ParameterReference
Internal compiler error at M.cs(13,22):: exception caught while emitting MethodBuilder [M::Main]

Unhandled Exception: System.Exception: Expression Mono.CSharp.ParameterReference did not set its type after Resolve
called from: Mono.CSharp.ParameterReference
  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.SimpleName.DoSimpleNameResolve (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression right_side, Boolean intermediate) [0x00000]
  at Mono.CSharp.SimpleName.SimpleNameResolve (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression right_side, Boolean intermediate) [0x00000]
  at Mono.CSharp.SimpleName.DoResolve (Mono.CSharp.EmitContext ec, Boolean intermediate) [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.Binary.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.Return.DoResolve (Mono.CSharp.EmitContext ec) [0x00000]
  at Mono.CSharp.ContextualReturn.DoResolve (Mono.CSharp.EmitContext ec) [0x00000]
  at Mono.CSharp.ExitStatement.Resolve (Mono.CSharp.EmitContext ec) [0x00000]
  at Mono.CSharp.Block.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]
$ gmcs --version
Mono C# compiler version 2.4.0.0


Expected Results:  
Compiler succeeds or gives error message
Comment 1 Jon Pryor 2009-06-14 03:59:52 UTC
Looks to be a duplicate of #424064 -- same error message, same stack trace.

*** This bug has been marked as a duplicate of bug 424064 ***