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=54789
  • Loading branch information...
1 parent e1fa37b commit fbe543ea490c34a576228384df989c0a9f549e30 @migueldeicaza migueldeicaza committed Dec 23, 2005
Showing with 24 additions and 0 deletions.
  1. +5 −0 mcs/gmcs/ChangeLog
  2. +19 −0 mcs/gmcs/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
@@ -764,8 +764,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 (", ");
@@ -919,6 +935,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 fbe543e

Please sign in to comment.