Fix while loops not breaking

This commit is contained in:
2018-12-09 14:33:04 +01:00
parent 00cc59dfbd
commit 74bc57bb1a

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;
}
}
}