mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Fixed incorrect warning for flipped CheckConstCompare
This commit is contained in:
parent
6fcecfdb78
commit
1014824fd0
2 changed files with 7 additions and 4 deletions
|
@ -24485,7 +24485,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfExpression* leftExpression, BfExp
|
|||
PerformBinaryOperation(leftExpression, rightExpression, binaryOp, opToken, flags, leftValue);
|
||||
}
|
||||
|
||||
bool BfExprEvaluator::CheckConstCompare(BfBinaryOp binaryOp, BfAstNode* opToken, const BfTypedValue& leftValue, const BfTypedValue& rightValue)
|
||||
bool BfExprEvaluator::CheckConstCompare(BfBinaryOp binaryOp, BfAstNode* opToken, const BfTypedValue& leftValue, const BfTypedValue& rightValue, bool invert)
|
||||
{
|
||||
if ((binaryOp < BfBinaryOp_Equality) || (binaryOp > BfBinaryOp_LessThanOrEqual))
|
||||
return false;
|
||||
|
@ -24613,13 +24613,16 @@ bool BfExprEvaluator::CheckConstCompare(BfBinaryOp binaryOp, BfAstNode* opToken,
|
|||
}
|
||||
}
|
||||
|
||||
if ((invert) && (constResult >= 0))
|
||||
constResult ^= 1;
|
||||
|
||||
if (constResult == 0)
|
||||
{
|
||||
mModule->Warn(0, "The result of this operation is always 'false'", opToken);
|
||||
mResult = BfTypedValue(mModule->mBfIRBuilder->CreateConst(BfTypeCode_Boolean, 0), mModule->GetPrimitiveType(BfTypeCode_Boolean));
|
||||
return true;
|
||||
}
|
||||
else if (constResult == 1)
|
||||
else if (constResult == 1)
|
||||
{
|
||||
mModule->Warn(0, "The result of this operation is always 'true'", opToken);
|
||||
mResult = BfTypedValue(mModule->mBfIRBuilder->CreateConst(BfTypeCode_Boolean, 1), mModule->GetPrimitiveType(BfTypeCode_Boolean));
|
||||
|
@ -24672,7 +24675,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
|
|||
}
|
||||
else if ((leftValue.mValue.IsConst()) && (!rightValue.mValue.IsConst()))
|
||||
{
|
||||
if (CheckConstCompare(BfGetOppositeBinaryOp(binaryOp), opToken, rightValue, leftValue))
|
||||
if (CheckConstCompare(BfGetOppositeBinaryOp(binaryOp), opToken, rightValue, leftValue, true))
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -488,7 +488,7 @@ public:
|
|||
void LookupQualifiedName(BfAstNode* nameNode, BfIdentifierNode* nameLeft, BfIdentifierNode* nameRight, bool ignoreInitialError, bool* hadError = NULL);
|
||||
void LookupQualifiedStaticField(BfQualifiedNameNode* nameNode, bool ignoreIdentifierNotFoundError);
|
||||
void LookupQualifiedStaticField(BfAstNode* nameNode, BfIdentifierNode* nameLeft, BfIdentifierNode* nameRight, bool ignoreIdentifierNotFoundError);
|
||||
bool CheckConstCompare(BfBinaryOp binaryOp, BfAstNode* opToken, const BfTypedValue& leftValue, const BfTypedValue& rightValue);
|
||||
bool CheckConstCompare(BfBinaryOp binaryOp, BfAstNode* opToken, const BfTypedValue& leftValue, const BfTypedValue& rightValue, bool invert = false);
|
||||
void AddStrings(const BfTypedValue& leftValue, const BfTypedValue& rightValue, BfAstNode* refNode);
|
||||
bool PerformBinaryOperation_NullCoalesce(BfTokenNode* opToken, BfExpression* leftExpression, BfExpression* rightExpression, BfTypedValue leftValue, BfType* wantType, BfTypedValue* assignTo = NULL);
|
||||
bool PerformBinaryOperation_Numeric(BfAstNode* leftExpression, BfAstNode* rightExpression, BfBinaryOp binaryOp, BfAstNode* opToken, BfBinOpFlags flags, BfTypedValue leftValue, BfTypedValue rightValue);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue