From 01d408e5fd1b405938ad924c384192e5177de373 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 20 Jan 2019 22:57:18 +0100 Subject: [PATCH] Fixes for modules and function binding --- .../ScriptFunction/ScriptRuntimeFunction.cs | 3 +++ Upsilon/Binder/Binder.cs | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Upsilon/BaseTypes/ScriptFunction/ScriptRuntimeFunction.cs b/Upsilon/BaseTypes/ScriptFunction/ScriptRuntimeFunction.cs index 4f8fe59..1132449 100644 --- a/Upsilon/BaseTypes/ScriptFunction/ScriptRuntimeFunction.cs +++ b/Upsilon/BaseTypes/ScriptFunction/ScriptRuntimeFunction.cs @@ -77,6 +77,9 @@ namespace Upsilon.BaseTypes.ScriptFunction { var callingVariable = variables[index]; var optionVariable = option.Parameters[index]; + if (callingVariable.Type == BaseTypes.Type.Unknown || callingVariable.Type == BaseTypes.Type.Nil || + optionVariable.Type == BaseTypes.Type.Unknown) + continue; if (callingVariable.Type != optionVariable.Type) { isCompatible = false; diff --git a/Upsilon/Binder/Binder.cs b/Upsilon/Binder/Binder.cs index f3ae074..dccd6d8 100644 --- a/Upsilon/Binder/Binder.cs +++ b/Upsilon/Binder/Binder.cs @@ -258,12 +258,16 @@ namespace Upsilon.Binder unbound = functionExpression; break; } - unbound.Block = (BoundBlockStatement) BindBlockStatement(unbound.UnboundBlock); - returnType = Scope.ReturnType; - Scope = Scope.ParentScope; - functionOption.IsBound = true; - functionOption.ResultType = returnType; + if (unbound != null) + { + unbound.Block = (BoundBlockStatement) BindBlockStatement(unbound.UnboundBlock); + + returnType = Scope.ReturnType; + Scope = Scope.ParentScope; + functionOption.IsBound = true; + functionOption.ResultType = returnType; + } } }