mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
No error on return type mismatch on NoReturn expression-bodied calls
This commit is contained in:
parent
2de490fd59
commit
3ef627e3e2
3 changed files with 8 additions and 1 deletions
|
@ -8149,6 +8149,12 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
|
|||
auto func = moduleMethodInstance.mFunc;
|
||||
BfTypedValue callResult = CreateCall(targetSrc, methodInstance, func, bypassVirtual, irArgs, NULL, physCallFlags);
|
||||
|
||||
if ((methodInstance->mMethodDef->mIsNoReturn) && ((mBfEvalExprFlags & BfEvalExprFlags_IsExpressionBody) != 0) &&
|
||||
(mExpectingType != NULL) && (callResult.mType != mExpectingType))
|
||||
{
|
||||
callResult = mModule->GetDefaultTypedValue(mExpectingType);
|
||||
}
|
||||
|
||||
// This gets triggered for non-sret (ie: comptime) composite returns so they aren't considered readonly
|
||||
if ((callResult.mKind == BfTypedValueKind_Value) && (!callResult.mValue.IsConst()) &&
|
||||
(!callResult.mType->IsValuelessType()) && (callResult.mType->IsComposite()) && (!methodInstance->GetLoweredReturnType()))
|
||||
|
|
|
@ -21179,7 +21179,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
|
|||
// Warn(0, "Using a 'void' return with an expression-bodied method isn't needed. Consider removing '=>' token", methodDeclaration->mFatArrowToken);
|
||||
// }
|
||||
|
||||
BfEvalExprFlags exprEvalFlags = BfEvalExprFlags_AllowRefExpr;
|
||||
BfEvalExprFlags exprEvalFlags = (BfEvalExprFlags)(BfEvalExprFlags_AllowRefExpr | BfEvalExprFlags_IsExpressionBody);
|
||||
if (expectingType->IsVoid())
|
||||
{
|
||||
exprEvalFlags = (BfEvalExprFlags)(exprEvalFlags | BfEvalExprFlags_NoCast);
|
||||
|
|
|
@ -85,6 +85,7 @@ enum BfEvalExprFlags
|
|||
BfEvalExprFlags_FromConversionOp = 0x8000000,
|
||||
BfEvalExprFlags_FromConversionOp_Explicit = 0x10000000,
|
||||
BfEvalExprFlags_AllowGenericConstValue = 0x20000000,
|
||||
BfEvalExprFlags_IsExpressionBody = 0x40000000,
|
||||
|
||||
BfEvalExprFlags_InheritFlags = BfEvalExprFlags_NoAutoComplete | BfEvalExprFlags_Comptime | BfEvalExprFlags_DeclType
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue