diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp
index ff2d3f8eb8..cb5944ade4 100644
--- a/src/scripting/codegeneration/codegen.cpp
+++ b/src/scripting/codegeneration/codegen.cpp
@@ -8133,7 +8133,7 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx)
 				if (ArgList[i]->ValueType == TypeName ||
 					ArgList[i]->ValueType == TypeSound)
 				{
-					FxExpression* x = new FxStringCast(ArgList[i]);
+					x = new FxStringCast(ArgList[i]);
 					x = x->Resolve(ctx);
 				}
 				else x = ArgList[i];