From 812ec7137b719afd50fb251c449bf39ce92cfafe Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 17 Feb 2019 17:53:22 +0100 Subject: [PATCH] Fix coroutines breaking on if statements --- Upsilon/Binder/BoundStatements/BoundIfStatement.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Upsilon/Binder/BoundStatements/BoundIfStatement.cs b/Upsilon/Binder/BoundStatements/BoundIfStatement.cs index afe3dc0..d14ed51 100644 --- a/Upsilon/Binder/BoundStatements/BoundIfStatement.cs +++ b/Upsilon/Binder/BoundStatements/BoundIfStatement.cs @@ -64,14 +64,17 @@ namespace Upsilon.Binder var condition = Condition.Expression.Evaluate(scope, diagnostics, ref state); if ((ScriptBoolean) condition) { - return Block.EvaluateCoroutine(scope, diagnostics, state); + yield return Block.EvaluateCoroutine(scope, diagnostics, state); } if (NextElseIf != null) { - return NextElseIf.EvaluateCoroutine(scope, diagnostics, state); + yield return NextElseIf.EvaluateCoroutine(scope, diagnostics, state); + } + if (ElseStatement != null) + { + yield return ElseStatement.EvaluateCoroutine(scope, diagnostics, state); } - return ElseStatement?.EvaluateCoroutine(scope, diagnostics, state); } }