Fix while loops not breaking

This commit is contained in:
Deukhoofd 2018-12-09 14:33:04 +01:00
parent 00cc59dfbd
commit 74bc57bb1a
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 4 additions and 2 deletions

View File

@ -705,7 +705,7 @@ namespace Upsilon.Evaluator
if (e.Variables[1].Name != "_")
innerEvaluator.Scope.CreateLocal(e.Variables[1], table[1]);
innerEvaluator.EvaluateBoundBlockStatement((BoundBlockStatement) e.Block);
if (innerEvaluator.HasBroken)
if (innerEvaluator.HasBroken || innerEvaluator.HasReturned)
break;
}
}
@ -716,9 +716,11 @@ namespace Upsilon.Evaluator
var innerEvaluator = new Evaluator(_diagnostics, Scope, _script);
var block = (BoundBlockStatement) e.Block;
while ((ScriptBoolean)EvaluateExpression(e.Condition))
while ((ScriptBoolean)innerEvaluator.EvaluateExpression(e.Condition))
{
innerEvaluator.EvaluateBoundBlockStatement(block);
if (innerEvaluator.HasBroken || innerEvaluator.HasReturned)
break;
}
}
}