From a98e1c47383596fb9e74a552d60bf4643b17195d Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Fri, 5 Mar 2021 15:10:20 +0100 Subject: [PATCH] Initialize values on nil --- AspectedRouting/IO/LuaSkeleton/LuaSkeleton.Function.cs | 6 +++--- AspectedRouting/IO/LuaSnippets/ListFoldingSnippet.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AspectedRouting/IO/LuaSkeleton/LuaSkeleton.Function.cs b/AspectedRouting/IO/LuaSkeleton/LuaSkeleton.Function.cs index 710b6d3..65d69b3 100644 --- a/AspectedRouting/IO/LuaSkeleton/LuaSkeleton.Function.cs +++ b/AspectedRouting/IO/LuaSkeleton/LuaSkeleton.Function.cs @@ -59,9 +59,9 @@ namespace AspectedRouting.IO.LuaSkeleton "Returns values: ", "]]", "function " + meta.Name.AsLuaIdentifier() + "(parameters, tags, result)" + funcNameDeclaration, - " local result", - " "+Snippets.Convert(this, "result", expression).Indent(), - " return result" , + " local r = nil", + " "+Snippets.Convert(this, "r", expression).Indent(), + " return r" , "end" ); diff --git a/AspectedRouting/IO/LuaSnippets/ListFoldingSnippet.cs b/AspectedRouting/IO/LuaSnippets/ListFoldingSnippet.cs index d7f5365..09119b1 100644 --- a/AspectedRouting/IO/LuaSnippets/ListFoldingSnippet.cs +++ b/AspectedRouting/IO/LuaSnippets/ListFoldingSnippet.cs @@ -45,12 +45,12 @@ namespace AspectedRouting.IO.LuaSnippets } else { tags = lua.FreeVar("tags"); - result += "local " + tags + "\n"; + result += "local " + tags + " = nil\n"; result += Snippets.Convert(lua, tags, mappingArg); } var m = lua.FreeVar("m"); - result += " local " + m + "\n"; + result += " local " + m + " = nil\n"; foreach (var (key, func) in mapping.StringToResultFunctions) { result += "if (" + tags + "[\"" + key + "\"] ~= nil) then\n";