From 5d842fc79fd88c444d9c96cfabf069cee315a66d Mon Sep 17 00:00:00 2001 From: Jeff Hutchinson Date: Tue, 12 Sep 2023 22:07:28 -0400 Subject: [PATCH] TScript - Fix Type Bug The compiler was found to have a bug where the variable type cannot ever change, causing issues. --- Engine/source/console/compiler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Engine/source/console/compiler.cpp b/Engine/source/console/compiler.cpp index f898b89847..8b75ab2880 100644 --- a/Engine/source/console/compiler.cpp +++ b/Engine/source/console/compiler.cpp @@ -160,6 +160,12 @@ S32 FuncVars::assign(StringTableEntry var, TypeReq currentType, S32 lineNumber, std::unordered_map::iterator found = vars.find(var); if (found != vars.end()) { + // if we are calling assign more than once AND it changes type, we don't know what the variable type is as this is a + // dynamically typed language. So we will assign to None and bail. None will be taken care of by the code to always + // load what the default type is (What Globals and arrays use, type None). + if (currentType != found->second.currentType && found->second.currentType != TypeReqNone) + found->second.currentType = TypeReqNone; + if (found->second.isConstant) { const char* str = avar("Script Warning: Reassigning variable %s when it is a constant. File: %s Line : %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber);