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

Made comparison of valueless types be constant bools

This commit is contained in:
Brian Fiete 2020-06-29 12:17:14 -07:00
parent 7d680c2a48
commit fb7251e71a

View file

@ -18593,6 +18593,15 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
return;
}
}
// Valueless types always compare as 'equal'
if ((leftValue.mType == rightValue.mType) && (leftValue.mType->IsValuelessType()))
{
auto boolType = mModule->GetPrimitiveType(BfTypeCode_Boolean);
bool isEqual = (binaryOp == BfBinaryOp_Equality) || (binaryOp == BfBinaryOp_StrictEquality);
mResult = BfTypedValue(mModule->GetConstValue(isEqual ? 1 : 0, boolType), boolType);
return;
}
}
if ((leftValue.mType->IsTypeInstance()) || (leftValue.mType->IsGenericParam()) ||