mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Made better error for class &this attempt
This commit is contained in:
parent
f8b27c13a2
commit
cd51b72a7d
1 changed files with 11 additions and 2 deletions
|
@ -14609,11 +14609,16 @@ bool BfExprEvaluator::CheckModifyResult(BfTypedValue typedVal, BfAstNode* refNod
|
|||
else
|
||||
error = mModule->Fail(StrFormat("Cannot %s 'this' within struct lambda. Consider adding by-reference capture specifier [&] to lambda.", modifyType), refNode);
|
||||
}
|
||||
else
|
||||
else if (localVar->mResolvedType->IsValueType())
|
||||
{
|
||||
error = mModule->Fail(StrFormat("Cannot %s 'this' within struct method '%s'. Consider adding 'mut' specifier to this method.", modifyType,
|
||||
mModule->MethodToString(mModule->mCurMethodInstance).c_str()), refNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
error = mModule->Fail(StrFormat("Cannot %s 'this' because '%s' is a reference type.", modifyType,
|
||||
mModule->TypeToString(localVar->mResolvedType).c_str()), refNode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (mResultFieldInstance != NULL)
|
||||
|
@ -17171,8 +17176,10 @@ void BfExprEvaluator::PerformUnaryOperation_OnResult(BfExpression* unaryOpExpr,
|
|||
mModule->Fail(StrFormat("Invalid usage of '%s' expression", BfGetOpName(unaryOp)), opToken);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ResolveGenericType();
|
||||
if (mResult.mType->IsVar())
|
||||
break;
|
||||
mResult = BfTypedValue(mResult.mValue, mModule->CreateRefType(mResult.mType, (unaryOp == BfUnaryOp_Ref) ? BfRefType::RefKind_Ref : BfRefType::RefKind_Mut));
|
||||
}
|
||||
break;
|
||||
|
@ -17199,6 +17206,8 @@ void BfExprEvaluator::PerformUnaryOperation_OnResult(BfExpression* unaryOpExpr,
|
|||
|
||||
MarkResultUsed();
|
||||
ResolveGenericType();
|
||||
if (mResult.mType->IsVar())
|
||||
break;
|
||||
mResult = BfTypedValue(mResult.mValue, mModule->CreateRefType(mResult.mType, BfRefType::RefKind_Out));
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue