From 7a4a7bd2fb3edc376b62a0d200d7a22a825a4b36 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Sat, 1 Jan 2022 11:08:01 -0500 Subject: [PATCH] Fixed erroneous 'int' widening during binary operation --- IDEHelper/Compiler/BfExprEvaluator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 239fe6d5..ce32e1b2 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -20850,6 +20850,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfExpression* leftExpression, BfExp } BfType* wantType = leftValue.mType; + BfType* origWantType = wantType; if ((binaryOp == BfBinaryOp_LeftShift) || (binaryOp == BfBinaryOp_RightShift)) wantType = NULL; // Don't presume wantType = mModule->FixIntUnknown(wantType); @@ -20858,7 +20859,9 @@ void BfExprEvaluator::PerformBinaryOperation(BfExpression* leftExpression, BfExp return; BfType* rightWantType = wantType; - if ((mExpectingType != NULL) && (wantType != NULL) && (mExpectingType->IsIntegral()) && (wantType->IsIntegral()) && (mExpectingType->mSize > wantType->mSize) && + if (origWantType->IsIntUnknown()) + rightWantType = NULL; + else if ((mExpectingType != NULL) && (wantType != NULL) && (mExpectingType->IsIntegral()) && (wantType->IsIntegral()) && (mExpectingType->mSize > wantType->mSize) && ((binaryOp == BfBinaryOp_Add) || (binaryOp == BfBinaryOp_Subtract) || (binaryOp == BfBinaryOp_Multiply))) rightWantType = mExpectingType; rightValue = mModule->CreateValueFromExpression(rightExpression, rightWantType, (BfEvalExprFlags)((mBfEvalExprFlags & BfEvalExprFlags_InheritFlags) | BfEvalExprFlags_NoCast));