dlr bug
[mcs.git] / tests / test-anon-34.cs
blob3e75f7af74aea28647c50613c8acfbd8198f364e
1 //
2 // This test is from Nigel Perry, Bugzilla #77060
3 //
4 // The issue here was that in the past we used to emit the
5 // Scope initialization on first use, which is wrong as illustrated
6 // in this test (the shared scope is not initialized for differnt
7 // code paths).
8 //
9 // This test is a running test, ensuring that it runs
11 #region Using directives
13 using System;
14 using System.Collections;
15 using System.Text;
16 using System.Timers;
18 #endregion
20 namespace Delegates
21 { class Space
22 { public int Value;
24 public delegate void DoCopy();
26 public DoCopy CopyIt;
28 public void Leak(bool useArray, int max)
29 { DoCopy one = null;
31 if(useArray)
33 int[] work;
35 one = delegate
36 { work = new int[max];
39 else
41 one = delegate { int xans = (max + 1) * max / 2; };
44 Console.WriteLine("Here goes...");
45 one();
46 Console.WriteLine("... made it");
50 class Program
51 { static void SpaceLeak()
52 { Space s = new Space();
54 Console.WriteLine(s.Value);
56 s.Leak(false, 1);
58 Console.WriteLine(s.Value);
61 static void Main(string[] args)
62 { SpaceLeak();