Permalink
Browse files

2005-12-23 Miguel de Icaza <miguel@novell.com>

	* anonymous.cs (ScopeInfo.LinkScope): Do not link the scope to its
	parent if its the same scope.  Fixes #77060.

svn path=/branches/mono-1-1-12/mcs/; revision=54788
  • Loading branch information...
1 parent 089bcfe commit e1fa37b5132c09b8ca3a77531fdb55e35ab82136 @migueldeicaza migueldeicaza committed Dec 23, 2005
Showing with 24 additions and 0 deletions.
  1. +5 −0 mcs/mcs/ChangeLog
  2. +19 −0 mcs/mcs/anonymous.cs
View
@@ -1,3 +1,8 @@
+2005-12-23 Miguel de Icaza <miguel@novell.com>
+
+ * anonymous.cs (ScopeInfo.LinkScope): Do not link the scope to its
+ parent if its the same scope. Fixes #77060.
+
2005-12-14 Miguel de Icaza <miguel@novell.com>
* convert.cs (ExplicitConversionCore): Check the return value from
View
@@ -691,8 +691,24 @@ public void EmitScopeInstance (ILGenerator ig)
ig.Emit (OpCodes.Ldloc, scope_instance);
}
+ public static void CheckCycles (string msg, ScopeInfo s)
+ {
+ ArrayList l = new ArrayList ();
+ int n = 0;
+
+ for (ScopeInfo p = s; p != null; p = p.ParentScope,n++){
+ if (l.Contains (p)){
+ Console.WriteLine ("Loop detected {0} in {1}", n, msg);
+ throw new Exception ();
+ }
+ l.Add (p);
+ }
+ }
+
static void DoPath (StringBuilder sb, ScopeInfo start)
{
+ CheckCycles ("print", start);
+
if (start.ParentScope != null){
DoPath (sb, start.ParentScope);
sb.Append (", ");
@@ -846,6 +862,9 @@ void AdjustMethodScope (AnonymousContainer am, ScopeInfo scope)
void LinkScope (ScopeInfo scope, int id)
{
ScopeInfo parent = (ScopeInfo) scopes [id];
+ if (parent == scope)
+ return;
+
scope.ParentScope = parent;
parent.AddChild (scope);

0 comments on commit e1fa37b

Please sign in to comment.