From eff60375ea8aa2bf1c98f4e2ebcb357b9fe51336 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Thu, 15 Nov 2018 20:54:44 +0100 Subject: [PATCH] Bind functions even when they're not called, but with `Unknown` type parameters --- Upsilon/Binder/Binder.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Upsilon/Binder/Binder.cs b/Upsilon/Binder/Binder.cs index b0856da..2d83daf 100644 --- a/Upsilon/Binder/Binder.cs +++ b/Upsilon/Binder/Binder.cs @@ -25,6 +25,19 @@ namespace Upsilon.Binder public BoundScript BindScript(BlockStatementSyntax e) { var bound = BindStatement(e); + foreach (var unboundFunctionStatement in _unboundFunctions) + { + _scope = new BoundScope(_scope); + foreach (var valueParameter in unboundFunctionStatement.Value.Parameters) + { + _scope.SetVariable(valueParameter); + } + unboundFunctionStatement.Value.Block = + (BoundBlockStatement) BindBlockStatement(unboundFunctionStatement.Value.UnboundBlock); + _scope = _scope.ParentScope; + unboundFunctionStatement.Key.IsBound = true; + } + _unboundFunctions = new Dictionary(); return new BoundScript(bound); }