From 68d3f474ce3e30c58bc73e136cf4d5b8a755a019 Mon Sep 17 00:00:00 2001 From: CandiceJoy Date: Thu, 9 Feb 2023 15:58:19 -0600 Subject: [PATCH] Fixed an error where implicit pointer casts should've failed but didn't. Signed-off-by: CandiceJoy --- src/common/scripting/backend/codegen.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/common/scripting/backend/codegen.cpp b/src/common/scripting/backend/codegen.cpp index 09abbe6043d..cd41618379a 100644 --- a/src/common/scripting/backend/codegen.cpp +++ b/src/common/scripting/backend/codegen.cpp @@ -274,6 +274,14 @@ bool AreCompatiblePointerTypes(PType *dest, PType *source, bool forcompare) { auto fromtype = source->toPointer(); auto totype = dest->toPointer(); + // implicit pointer casts + if( fromtype->isClassPointer() && !totype->isClassPointer() ) totype->toClassPointer(fromtype); // just to make sure they're compatible pointer types + else if( !fromtype->isClassPointer() && totype->isClassPointer() ) fromtype->toClassPointer(totype); // just to make sure they're compatible pointer types + else if( fromtype->PointedType != totype->PointedType ) + { + auto res = fromtype->PointedType->toClass(totype->PointedType); + if(!res || res != totype->PointedType) return false; + } // null pointers can be assigned to everything, everything can be assigned to void pointers. if (fromtype == nullptr || totype == TypeVoidPtr) return true; // when comparing const-ness does not matter.