From 38e880e097b4043594a05fe079261ceda0e6aaeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Sat, 7 Oct 2023 11:44:44 -0300 Subject: [PATCH] change version, improve errors for array/map/struct copy --- src/common/scripting/backend/codegen.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/common/scripting/backend/codegen.cpp b/src/common/scripting/backend/codegen.cpp index 758f3cd6c3c..9711abf7289 100644 --- a/src/common/scripting/backend/codegen.cpp +++ b/src/common/scripting/backend/codegen.cpp @@ -2489,7 +2489,7 @@ FxExpression *FxAssign::Resolve(FCompileContext &ctx) if (btype->isDynArray()) { - if(ctx.Version >= MakeVersion(4, 11, 0)) + if(ctx.Version >= MakeVersion(4, 11, 1)) { FArgumentList args; args.Push(Right); @@ -2502,12 +2502,14 @@ FxExpression *FxAssign::Resolve(FCompileContext &ctx) { if(Base->ValueType->isRealPointer() && Right->ValueType->isRealPointer()) { - ScriptPosition.Message(MSG_WARNING, "Dynamic Array assignments not allowed in ZScript versions below 4.11, use the Copy() or Move() functions instead\n" - TEXTCOLOR_RED "!! Assigning an out array pointer to another out array pointer does not alter either of the underlying arrays' values below ZScript version 4.11 !!"); + ScriptPosition.Message(MSG_WARNING, "Dynamic Array assignments not allowed in ZScript versions below 4.11.1, use the Copy() or Move() functions instead\n" + TEXTCOLOR_RED " Assigning an out array pointer to another out array pointer\n" + " does not alter either of the underlying arrays' values\n" + " it only swaps the pointers below ZScript version 4.11.1!!"); } else { - ScriptPosition.Message(MSG_ERROR, "Dynamic Array assignments not allowed in ZScript versions below 4.11, use the Copy() or Move() functions instead"); + ScriptPosition.Message(MSG_ERROR, "Dynamic Array assignments not allowed in ZScript versions below 4.11.1, use the Copy() or Move() functions instead"); delete this; return nullptr; } @@ -2515,7 +2517,7 @@ FxExpression *FxAssign::Resolve(FCompileContext &ctx) } else if (btype->isMap()) { - if(ctx.Version >= MakeVersion(4, 11, 0)) + if(ctx.Version >= MakeVersion(4, 11, 1)) { FArgumentList args; args.Push(Right); @@ -2528,12 +2530,14 @@ FxExpression *FxAssign::Resolve(FCompileContext &ctx) { if(Base->ValueType->isRealPointer() && Right->ValueType->isRealPointer()) { // don't break existing code, but warn that it's a no-op - ScriptPosition.Message(MSG_WARNING, "Map assignments not allowed in ZScript versions below 4.11, use the Copy() or Move() functions instead\n" - TEXTCOLOR_RED "!! Assigning an out map pointer to another out map pointer does not alter either of the underlying maps' values below ZScript version 4.11 !!"); + ScriptPosition.Message(MSG_WARNING, "Map assignments not allowed in ZScript versions below 4.11.1, use the Copy() or Move() functions instead\n" + TEXTCOLOR_RED " Assigning an out map pointer to another out map pointer\n" + " does not alter either of the underlying maps' values\n" + " it only swaps the pointers below ZScript version 4.11.1!!"); } else { - ScriptPosition.Message(MSG_ERROR, "Map assignments not allowed in ZScript versions below 4.11, use the Copy() or Move() functions instead"); + ScriptPosition.Message(MSG_ERROR, "Map assignments not allowed in ZScript versions below 4.11.1, use the Copy() or Move() functions instead"); delete this; return nullptr; } @@ -2550,7 +2554,9 @@ FxExpression *FxAssign::Resolve(FCompileContext &ctx) if(Base->ValueType->isRealPointer() && Right->ValueType->isRealPointer()) { // don't break existing code, but warn that it's a no-op ScriptPosition.Message(MSG_WARNING, "Struct assignment not implemented yet\n" - TEXTCOLOR_RED "!! Assigning an out struct pointer to another out struct pointer does not alter either of the underlying structs' values !!"); + TEXTCOLOR_RED " Assigning an out struct pointer to another out struct pointer\n" + " does not alter either of the underlying structs' values\n" + " it only swaps the pointers!!"); } else {