Bug 320850 (MONO78104) - [ANONYMOUS METHODS] (FIXED) yield in 'using' statement cause gmcs compiler crashed
Summary: [ANONYMOUS METHODS] (FIXED) yield in 'using' statement cause gmcs compiler cr...
Status: RESOLVED FIXED
Alias: MONO78104
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other All
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Martin Baulig
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-14 12:52 UTC by Red Forks
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:55:03 UTC


---- Reported by redforks@gmail.com 2006-04-14 05:52:27 MST ----

Description of Problem:
  When gmcs compile following c# code, gmcs will encounded Unhandled 
Exception: 
  Unhandled Exception: System.Exception: Trying to emit a local from a 
different ILGenerator.
  
  mono versions: 1.1.13.4, 1.1.14.0


Steps to reproduce the problem:
1. save the t.cs to disk
2. run gmcs t.cs


Actual Results:
Unhandled Exception

Expected Results:
Success

How often does this happen? 
Every time.

Additional Information:


using System;
using System.Collections;

class NeedDispose: IDisposable
{
  public void Dispose() { }
}

public class IterTest : IEnumerable<string>
{
  public IEnumerator GetEnumerator()
  {
    using (new NeedDispose()) {
      yield return "a";
      yield return "b";
    }
  }
  
  public static void Main()
  {
    foreach (string s in new IterTest())
      Console.WriteLine(s);
  }
}



---- Additional Comments From atsushi@ximian.com 2006-04-25 22:41:31 MST ----

couple of problems:

- The example code should result in an error. IEnumerable<T> is in
System.Collections.Generic which is not referenced.
- The latest mcs in svn(trunk) does not raise such an error, so if
there was such a problem it is already fixed.
- This bug is absolutely not a critical one.




---- Additional Comments From redforks@gmail.com 2006-07-13 23:50:44 MST ----

The correct code also crashes gmcs:

using System;
using System.Collections;

class NeedDispose: IDisposable
{
  public void Dispose() { }
}

public class IterTest : IEnumerable
{
  public IEnumerator GetEnumerator()
  {
    using (new NeedDispose()) {
      yield return "a";
      yield return "b";
    }
  }

  public static void Main()
  {
    foreach (string s in new IterTest())
      Console.WriteLine(s);
  }
}

Both generic and non-generic version of IEnumerator will crashes.



---- Additional Comments From martin@ximian.com 2006-09-12 13:10:32 MST ----

*** https://bugzilla.novell.com/show_bug.cgi?id=MONO78717 has been marked as a duplicate of this bug. ***



---- Additional Comments From martin@ximian.com 2006-10-04 18:19:16 MST ----

Fixed in SVN.


Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>windows xp, GNU/Linux (gentoo)</cf_op_sys_details>