1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00

Fixed payload enum switch case comparison

This commit is contained in:
Brian Fiete 2023-07-24 10:32:31 -07:00
parent 52f746aae9
commit 11bde5caf2
5 changed files with 65 additions and 1 deletions

View file

@ -4707,6 +4707,7 @@ void BfModule::Visit(BfSwitchStatement* switchStmt)
BfTypedValue caseValue;
BfIRBlock doBlock = caseBlock;
bool hadConditional = false;
bool isEnumDescValue = isPayloadEnum;
if (isPayloadEnum)
{
auto dscrType = switchValue.mType->ToTypeInstance()->GetDiscriminatorType();
@ -4766,6 +4767,7 @@ void BfModule::Visit(BfSwitchStatement* switchStmt)
caseValue = CreateValueFromExpression(caseExpr, switchValue.mType, (BfEvalExprFlags)(BfEvalExprFlags_AllowEnumId | BfEvalExprFlags_NoCast));
if (!caseValue)
continue;
isEnumDescValue = false;
}
BfTypedValue caseIntVal = caseValue;
@ -4835,7 +4837,7 @@ void BfModule::Visit(BfSwitchStatement* switchStmt)
BfExprEvaluator exprEvaluator(this);
BfAstNode* refNode = switchCase->mColonToken;
if ((caseValue.mType->IsPayloadEnum()) && (caseValue.mValue.IsConst()) && (switchValue.mType == caseValue.mType))
if ((caseValue.mType->IsPayloadEnum()) && (caseValue.mValue.IsConst()) && (switchValue.mType == caseValue.mType) && (isEnumDescValue))
{
if (!enumTagVal)
{