From f764cf19363a352321f7d547b9341ad2901a92df Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Sat, 21 Sep 2024 15:36:05 +0200 Subject: [PATCH] Avoid infinite recursion when coercing to base class reference --- oscar64/Parser.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index dd400e3..7d63856 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -6856,8 +6856,13 @@ bool Parser::CanCoerceExpression(Expression* exp, Declaration* type) Expression* Parser::CoerceExpression(Expression* exp, Declaration* type) { Declaration* tdec = exp->mDecType; + while (tdec->mType == DT_TYPE_REFERENCE || tdec->mType == DT_TYPE_RVALUEREF) tdec = tdec->mBase; + + if (type->mType == DT_TYPE_REFERENCE && type->mBase->mType == DT_TYPE_STRUCT && tdec->mType == DT_TYPE_STRUCT && type->mBase->IsSubType(tdec)) + return exp; + while (type->mType == DT_TYPE_REFERENCE || type->mType == DT_TYPE_RVALUEREF) type = type->mBase;