Bug 499009

Summary: Member Initialization introduces error
Product: [Mono] Mono: Compilers Reporter: Miguel de Icaza <miguel>
Component: C#Assignee: Mono Bugs <mono-bugs>
Status: RESOLVED DUPLICATE QA Contact: Mono Bugs <mono-bugs>
Severity: Normal    
Priority: P5 - None    
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Miguel de Icaza 2009-04-28 21:36:17 UTC
The problem that we have is that we should only assign the result of the new operation until we have finished initializing.   This problem was first discovered by ASP.NET MVC:

using System;

class Foo {
	public int P { get; set; }
	
}

class Y {
	static void Main ()
	{
		Foo foo = new Foo ();
		foo.P = 1;

		Do (foo);
		Console.WriteLine ("OK");
	}

	static void Do (Foo f)
	{
		f = new Foo () {
			P = f.P
		};
		if (f.P != 1)
			throw new Exception ("Error, this should have been 1");
	}
}
Comment 1 Marek Habersack 2009-04-29 05:51:47 UTC
This is a duplicate of #496922

*** This bug has been marked as a duplicate of bug 496922 ***