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

Improved 'var' inference for binary operations

This commit is contained in:
Brian Fiete 2020-07-04 10:38:46 -07:00
parent 0d0d55741d
commit 39ad1dbe85

View file

@ -18512,7 +18512,13 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
if ((resultType->IsVar()) || (otherType->IsVar()))
{
mResult = mModule->GetDefaultTypedValue(resultType);
bool isComparison = (binaryOp >= BfBinaryOp_Equality) && (binaryOp <= BfBinaryOp_LessThanOrEqual);
if (isComparison)
mResult = mModule->GetDefaultTypedValue(mModule->GetPrimitiveType(BfTypeCode_Boolean), false, BfDefaultValueKind_Addr);
else if (mExpectingType != NULL)
mResult = mModule->GetDefaultTypedValue(mExpectingType, false, BfDefaultValueKind_Addr);
else
mResult = mModule->GetDefaultTypedValue(resultType, false, BfDefaultValueKind_Addr);
return;
}