1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00

Properly throw error on Dispose call on using for immutable values

This commit is contained in:
Brian Fiete 2019-09-29 07:43:36 -07:00
parent dfbf7a2792
commit f8d4d0ded0
2 changed files with 5 additions and 7 deletions

View file

@ -4566,17 +4566,11 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
(!isSkipCall))
{
bool skipMutCheck = false;
if (prevBindResult.mPrevVal != NULL)
if ((prevBindResult.mPrevVal != NULL) && (prevBindResult.mPrevVal->mSkipMutCheck))
{
// If we are binding a delegate, then we will end up making a copy of the target anyway
// so we don't need to do a mutability check
skipMutCheck = true;
// auto bindResult = prevBindResult.mPrevVal;
// if ((bindResult->mOrigTarget) &&
// ((bindResult->mOrigTarget.mType->IsVar()) || (bindResult->mOrigTarget.mType->IsPointer())))
// {
// skipMutCheck = true;
// }
}
PushThis(targetSrc, target, moduleMethodInstance.mMethodInstance, irArgs, skipMutCheck);
@ -8104,6 +8098,7 @@ bool BfExprEvaluator::CanBindDelegate(BfDelegateBindExpression* delegateBindExpr
methodGenericArguments = &delegateBindExpr->mGenericArgs->mGenericArgs;
BfFunctionBindResult bindResult;
bindResult.mSkipMutCheck = true; // Allow operating on copies
mFunctionBindResult = &bindResult;
SetAndRestoreValue<bool> ignoreError(mModule->mIgnoreErrors, true);
DoInvocation(delegateBindExpr->mTarget, delegateBindExpr, args, methodGenericArguments);
@ -8505,6 +8500,7 @@ void BfExprEvaluator::Visit(BfDelegateBindExpression* delegateBindExpr)
}
BfFunctionBindResult bindResult;
bindResult.mSkipMutCheck = true; // Allow operating on copies
mFunctionBindResult = &bindResult;
DoInvocation(delegateBindExpr->mTarget, delegateBindExpr, args, methodGenericArguments);
mFunctionBindResult = NULL;

View file

@ -219,6 +219,7 @@ public:
BfIRValue mFunc;
BfMethodInstance* mMethodInstance;
bool mSkipThis;
bool mSkipMutCheck;
bool mWantsArgs;
bool mCheckedMultipleMethods;
SizedArray<BfIRValue, 2> mIRArgs;
@ -227,6 +228,7 @@ public:
BfFunctionBindResult()
{
mMethodInstance = NULL;
mSkipMutCheck = false;
mWantsArgs = false;
mSkipThis = false;
mCheckedMultipleMethods = false;