mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-15 14:54:09 +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
|
else
|
||||||
error = mModule->Fail(StrFormat("Cannot %s 'this' within struct lambda. Consider adding by-reference capture specifier [&] to lambda.", modifyType), refNode);
|
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,
|
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);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
else if (mResultFieldInstance != NULL)
|
else if (mResultFieldInstance != NULL)
|
||||||
|
@ -17173,6 +17178,8 @@ void BfExprEvaluator::PerformUnaryOperation_OnResult(BfExpression* unaryOpExpr,
|
||||||
}
|
}
|
||||||
|
|
||||||
ResolveGenericType();
|
ResolveGenericType();
|
||||||
|
if (mResult.mType->IsVar())
|
||||||
|
break;
|
||||||
mResult = BfTypedValue(mResult.mValue, mModule->CreateRefType(mResult.mType, (unaryOp == BfUnaryOp_Ref) ? BfRefType::RefKind_Ref : BfRefType::RefKind_Mut));
|
mResult = BfTypedValue(mResult.mValue, mModule->CreateRefType(mResult.mType, (unaryOp == BfUnaryOp_Ref) ? BfRefType::RefKind_Ref : BfRefType::RefKind_Mut));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -17199,6 +17206,8 @@ void BfExprEvaluator::PerformUnaryOperation_OnResult(BfExpression* unaryOpExpr,
|
||||||
|
|
||||||
MarkResultUsed();
|
MarkResultUsed();
|
||||||
ResolveGenericType();
|
ResolveGenericType();
|
||||||
|
if (mResult.mType->IsVar())
|
||||||
|
break;
|
||||||
mResult = BfTypedValue(mResult.mValue, mModule->CreateRefType(mResult.mType, BfRefType::RefKind_Out));
|
mResult = BfTypedValue(mResult.mValue, mModule->CreateRefType(mResult.mType, BfRefType::RefKind_Out));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue