Fixed while/for loops not returning from function

This commit is contained in:
Deukhoofd 2018-12-10 17:03:04 +01:00
parent 5646ff1da1
commit 88e4b92b6a
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
2 changed files with 14 additions and 1 deletions

View File

@ -705,7 +705,14 @@ namespace Upsilon.Evaluator
innerEvaluator.Scope.CreateLocal(e.Variables[1], table[1]); innerEvaluator.Scope.CreateLocal(e.Variables[1], table[1]);
innerEvaluator.EvaluateBoundBlockStatement((BoundBlockStatement) e.Block); innerEvaluator.EvaluateBoundBlockStatement((BoundBlockStatement) e.Block);
if (innerEvaluator.HasBroken || innerEvaluator.HasReturned) if (innerEvaluator.HasBroken || innerEvaluator.HasReturned)
{
if (innerEvaluator.HasReturned)
{
HasReturned = innerEvaluator.HasReturned;
_returnValue = innerEvaluator._returnValue;
}
break; break;
}
} }
} }
} }
@ -719,7 +726,14 @@ namespace Upsilon.Evaluator
{ {
innerEvaluator.EvaluateBoundBlockStatement(block); innerEvaluator.EvaluateBoundBlockStatement(block);
if (innerEvaluator.HasBroken || innerEvaluator.HasReturned) if (innerEvaluator.HasBroken || innerEvaluator.HasReturned)
{
if (innerEvaluator.HasReturned)
{
HasReturned = innerEvaluator.HasReturned;
_returnValue = innerEvaluator._returnValue;
}
break; break;
}
} }
} }
} }

View File

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Linq; using System.Linq;
using Upsilon.Text;
namespace Upsilon.Parser namespace Upsilon.Parser
{ {