From 02fb3867e16c07c0761e809cf2bab20cb8a2555e Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 17 Feb 2019 17:54:14 +0100 Subject: [PATCH] Throw error if for some reason the execution of a statement in a coroutine returns null --- Upsilon/Binder/BoundStatements/BoundBlockStatement.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Upsilon/Binder/BoundStatements/BoundBlockStatement.cs b/Upsilon/Binder/BoundStatements/BoundBlockStatement.cs index 9b439da..d7a7f9b 100644 --- a/Upsilon/Binder/BoundStatements/BoundBlockStatement.cs +++ b/Upsilon/Binder/BoundStatements/BoundBlockStatement.cs @@ -39,6 +39,11 @@ namespace Upsilon.Binder foreach (var statement in Statements) { var coroutine = statement.EvaluateCoroutine(scope, diagnostics, state); + if (coroutine == null) + { + diagnostics.LogError("Can't evaluate a statement, it returned nil.", statement.Span); + continue; + } while (coroutine.MoveNext()) { yield return coroutine.Current;