Skip to content

Commit

Permalink
Fixed an error where implicit pointer casts should've failed but didn't.
Browse files Browse the repository at this point in the history
Signed-off-by: CandiceJoy <candice@candicejoy.com>
  • Loading branch information
CandiceJoy authored and madame-rachelle committed Feb 11, 2023
1 parent c41b075 commit 68d3f47
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/common/scripting/backend/codegen.cpp
Expand Up @@ -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.
Expand Down

0 comments on commit 68d3f47

Please sign in to comment.