[Mono-bugs] [Bug 79232][Min] New - mcs causes a crash with related to CS0236 (wrong field reference in delegate initializer)

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Aug 31 12:26:07 EDT 2006

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by atsushi at ximian.com.


--- shadow/79232	2006-08-31 12:26:07.000000000 -0400
+++ shadow/79232.tmp.1506	2006-08-31 12:26:07.000000000 -0400
@@ -0,0 +1,83 @@
+Bug#: 79232
+Product: Mono: Compilers
+Version: 1.1
+OS Details: 
+Status: NEW   
+Priority: Minor
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: atsushi at ximian.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: mcs causes a crash with related to CS0236 (wrong field reference in delegate initializer)
+When given the following code, mcs crashes.
+delegate void Foo ();
+class Test
+        object o1;
+        Foo h = delegate () {
+                o1 = null;
+        };
+Actual Results:
+Exception caught by the compiler while compiling:
+   Block that caused the problem begin at: 20060831.cs(7,10):
+                     Block being compiled:
+System.NullReferenceException: Object reference not set to an instance of
+an obj
+Unhandled Exception: System.NullReferenceException: Object reference not
+set to an instance of an object
+  at Mono.CSharp.EmitContext.CaptureThis () [0x00000]
+  at Mono.CSharp.This.ResolveBase (Mono.CSharp.EmitContext ec) [0x00000]
+  at Mono.CSharp.EmitContext.GetThis (Location loc) [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.DoResolveLValue (Mono.CSharp.EmitContext ec,
+Mono.CSharp.Expression right_side) [0x00000]
+  at Mono.CSharp.Expression.ResolveLValue (Mono.CSharp.EmitContext ec,
+Mono.CSharp.Expression right_side, Location loc) [0x00000]
+  at Mono.CSharp.Assign.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.ExpressionStatement.ResolveStatement
+(Mono.CSharp.EmitContext ec) [0x00000]
+  at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.EmitContext ec)
+  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)
+Expected Results:
+(with csc)
+20060831.cs(8,3): error CS0236: A field initializer cannot reference the
+        nonstatic field, method, or property 'Test.o1'
+20060831.cs(5,9): (Location of symbol related to previous error)
+How often does this happen? 
+Additional Information:
+haven't tried Martin's anonymous method diff. It might not happen with the
+patched version.

More information about the mono-bugs mailing list