mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Added error for 'readonly' on methods with non-ref return
This commit is contained in:
parent
b2cb8f74d3
commit
87ab0ad169
2 changed files with 8 additions and 6 deletions
|
@ -5410,7 +5410,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, BfMethodInstance*
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto val = mModule->GetDefaultTypedValue(returnType, true, (GetStructRetIdx(methodInstance) != -1) ? BfDefaultValueKind_Addr : BfDefaultValueKind_Value);
|
auto val = mModule->GetDefaultTypedValue(returnType, true, (GetStructRetIdx(methodInstance) != -1) ? BfDefaultValueKind_Addr : BfDefaultValueKind_Value);
|
||||||
if (val.mKind == BfTypedValueKind_Addr)
|
if (val.mKind == BfTypedValueKind_Addr)
|
||||||
val.mKind = BfTypedValueKind_RestrictedTempAddr;
|
val.mKind = BfTypedValueKind_RestrictedTempAddr;
|
||||||
|
|
|
@ -21850,11 +21850,6 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
|
||||||
{
|
{
|
||||||
BP_ZONE("BfModule::BfMethodDeclaration");
|
BP_ZONE("BfModule::BfMethodDeclaration");
|
||||||
|
|
||||||
if (mCurTypeInstance->IsFunctionFromTypeRef())
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We could trigger a DoMethodDeclaration from a const resolver or other location, so we reset it here
|
// We could trigger a DoMethodDeclaration from a const resolver or other location, so we reset it here
|
||||||
// to effectively make mIgnoreWrites method-scoped
|
// to effectively make mIgnoreWrites method-scoped
|
||||||
SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, mWantsIRIgnoreWrites || mCurMethodInstance->mIsUnspecialized || mCurTypeInstance->mResolvingVarField);
|
SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, mWantsIRIgnoreWrites || mCurMethodInstance->mIsUnspecialized || mCurTypeInstance->mResolvingVarField);
|
||||||
|
@ -22187,6 +22182,13 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
|
||||||
|
|
||||||
if (resolvedReturnType == NULL)
|
if (resolvedReturnType == NULL)
|
||||||
resolvedReturnType = GetPrimitiveType(BfTypeCode_Var);
|
resolvedReturnType = GetPrimitiveType(BfTypeCode_Var);
|
||||||
|
|
||||||
|
if ((methodDef->mIsReadOnly) && (!resolvedReturnType->IsRef()))
|
||||||
|
{
|
||||||
|
if (auto methodDeclaration = BfNodeDynCast<BfMethodDeclaration>(methodInstance->mMethodDef->mMethodDeclaration))
|
||||||
|
if (methodDeclaration->mReadOnlySpecifier != NULL)
|
||||||
|
Fail("Readonly specifier is only valid on 'ref' return types", methodDeclaration->mReadOnlySpecifier);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue