[659970] Close anonymous method scope also for top-level blocks
authorMarek Safar <marek.safar@gmail.com>
Thu, 16 Dec 2010 18:22:30 +0000 (18:22 +0000)
committerMarek Safar <marek.safar@gmail.com>
Thu, 16 Dec 2010 18:24:28 +0000 (18:24 +0000)
mcs/mcs/cs-parser.jay
mcs/tests/test-anon-83.cs [new file with mode: 0644]

index 06f6ceccf07c0f57ec41951855dce37f4044f386..6a9e1929176e1a8a4986a19798e5fb98fe262f97 100644 (file)
@@ -6250,6 +6250,7 @@ void start_block (Location loc)
 {
        if (current_block == null) {
                current_block = new ToplevelBlock (compiler, current_local_parameters, loc);
+               parsing_anonymous_method = false;
        } else if (parsing_anonymous_method) {
                current_block = new ParametersBlock (current_block, current_local_parameters, loc);
                parsing_anonymous_method = false;
diff --git a/mcs/tests/test-anon-83.cs b/mcs/tests/test-anon-83.cs
new file mode 100644 (file)
index 0000000..879c2c8
--- /dev/null
@@ -0,0 +1,20 @@
+using System;
+
+public class C
+{
+       public event EventHandler MyDelegate = delegate { };
+
+       internal void DoSomething (bool bValue)
+       {
+               if (!bValue) {
+                       // It has to be here to check we are closing correctly top-block
+                       return;
+               }
+       }
+       
+       public static void Main ()
+       {
+       }
+}
+
+