[mcs] Initial lambda checked scope comes from parent block.
authorMarek Safar <marek.safar@gmail.com>
Fri, 17 Jan 2014 10:32:15 +0000 (11:32 +0100)
committerMarek Safar <marek.safar@gmail.com>
Fri, 17 Jan 2014 10:33:35 +0000 (11:33 +0100)
mcs/mcs/context.cs
mcs/tests/gtest-lambda-32.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_5.xml

index 5ab84f260afd3ae85e8d9c6ee75f1e70c1582a97..8cbaeff0c5464d7956eebd1f5039ffa632e52e83 100644 (file)
@@ -97,6 +97,9 @@ namespace Mono.CSharp
                        if (rc.HasSet (ResolveContext.Options.CheckedScope))
                                flags |= ResolveContext.Options.CheckedScope;
 
+                       if (!rc.ConstantCheckState)
+                               flags &= ~Options.ConstantCheckState;
+
                        if (rc.IsInProbingMode)
                                flags |= ResolveContext.Options.ProbingMode;
 
diff --git a/mcs/tests/gtest-lambda-32.cs b/mcs/tests/gtest-lambda-32.cs
new file mode 100644 (file)
index 0000000..a46f1e4
--- /dev/null
@@ -0,0 +1,13 @@
+using System;
+
+class X
+{
+       const int Value = 1000;
+
+       static void Main ()
+       { 
+               unchecked { 
+                       Func<byte> b = () => (byte)X.Value;
+               } 
+       }
+}
\ No newline at end of file
index 63024af61d6bd49198407e205b0b6f724ffed819..c76dd77f5422ad0fe06bafa44503e6c60d06f2f3 100644 (file)
       </method>\r
     </type>\r
   </test>\r
+  <test name="gtest-lambda-32.cs">\r
+    <type name="X">\r
+      <method name="Void Main()" attrs="145">\r
+        <size>34</size>\r
+      </method>\r
+      <method name="Byte &lt;Main&gt;m__0()" attrs="145">\r
+        <size>13</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+  </test>\r
   <test name="gtest-linq-01.cs">\r
     <type name="from.C">\r
       <method name="Void Main()" attrs="150">\r