Skip to content

Commit

Permalink
- hopefully fixed the "is" operator to work with readonly pointers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Player701 authored and madame-rachelle committed Aug 2, 2023
1 parent 5a74e79 commit eec08f0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/common/scripting/backend/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ bool AreCompatiblePointerTypes(PType *dest, PType *source, bool forcompare)
// 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.
if (!forcompare && totype->IsConst != fromtype->IsConst) return false;
// If not comparing, then we should not allow const to be cast away.
if (!forcompare && fromtype->IsConst && !totype->IsConst) return false;
// A type is always compatible to itself.
if (fromtype == totype) return true;
// Pointers to different types are only compatible if both point to an object and the source type is a child of the destination type.
Expand Down Expand Up @@ -4793,7 +4794,7 @@ FxExpression *FxTypeCheck::Resolve(FCompileContext& ctx)
}
else
{
left = new FxTypeCast(left, NewPointer(RUNTIME_CLASS(DObject)), false);
left = new FxTypeCast(left, NewPointer(RUNTIME_CLASS(DObject), true), false);
ClassCheck = false;
}
right = new FxClassTypeCast(NewClassPointer(RUNTIME_CLASS(DObject)), right, false);
Expand Down

0 comments on commit eec08f0

Please sign in to comment.