1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-26 19:48:01 +02:00

Merge pull request #1001 from EinBurgbauer/unary-crash-fix

fixed crash when writing static unary operator
This commit is contained in:
Brian Fiete 2021-05-02 07:04:14 -04:00 committed by GitHub
commit 58f6693434
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18586,17 +18586,20 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
{ {
if (methodDef->mIsStatic) if (methodDef->mIsStatic)
{ {
auto checkParam0 = mCurMethodInstance->GetParamType(0);
if ((checkParam0->IsRef()) && (!checkParam0->IsOut()))
checkParam0 = checkParam0->GetUnderlyingType();
if (methodDef->mParams.size() != 1) if (methodDef->mParams.size() != 1)
{ {
Fail("Unary operators must declare one parameter", paramErrorRefNode); Fail("Unary operators must declare one parameter", paramErrorRefNode);
} }
else if ((checkParam0 != mCurTypeInstance) && (!checkParam0->IsSelf())) else
{ {
Fail("The parameter of a unary operator must be the containing type", paramErrorRefNode); auto checkParam0 = mCurMethodInstance->GetParamType(0);
if ((checkParam0->IsRef()) && (!checkParam0->IsOut()))
checkParam0 = checkParam0->GetUnderlyingType();
if ((checkParam0 != mCurTypeInstance) && (!checkParam0->IsSelf()))
{
Fail("The parameter of a unary operator must be the containing type", paramErrorRefNode);
}
} }
if (((operatorDef->mOperatorDeclaration->mUnaryOp == BfUnaryOp_Increment) || if (((operatorDef->mOperatorDeclaration->mUnaryOp == BfUnaryOp_Increment) ||