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

Fixed result-of-tuple crash

This commit is contained in:
Brian Fiete 2020-06-19 06:40:40 -07:00
parent 3863166545
commit 407c742bf9
2 changed files with 19 additions and 8 deletions

View file

@ -6429,7 +6429,6 @@ BfTypedValue BfExprEvaluator::CheckEnumCreation(BfAstNode* targetSrc, BfTypeInst
{
// argValue can have a value even if tuplePtr does not have a value. This can happen if we are assigning to a (void) tuple,
// but we have a value that needs to be attempted to be casted to void
argValue = mModule->Cast(argValues.mResolvedArgs[tupleFieldIdx].mExpression, argValue, resolvedFieldType);
if (tupleFieldPtr)
{
@ -11417,10 +11416,13 @@ void BfExprEvaluator::Visit(BfLambdaBindExpression* lambdaBindExpr)
capturedValue = capturedTypedVal.mValue;
if (capturedValue)
{
if (!capturedTypedVal.mType->IsVar())
{
auto fieldPtr = mModule->mBfIRBuilder->CreateInBoundsGEP(mResult.mValue, 0, fieldInstance->mDataIdx);
mModule->mBfIRBuilder->CreateStore(capturedValue, fieldPtr);
}
}
else
{
mModule->Fail(StrFormat("Unable to capture '%s'", capturedEntry.mName.c_str()), lambdaBindExpr);
@ -14638,11 +14640,19 @@ BfModuleMethodInstance BfExprEvaluator::GetPropertyMethodInstance(BfMethodDef* m
auto propTypeInst = mPropTarget.mType->ToTypeInstance();
auto rawMethodInstance = mModule->GetRawMethodInstance(propTypeInst, methodDef);
BF_ASSERT(rawMethodInstance->mVirtualTableIdx != -1);
if (rawMethodInstance->mVirtualTableIdx == -1)
{
mModule->Fail(StrFormat("Failed to devirtualize %s", mModule->MethodToString(rawMethodInstance).c_str()));
}
else
{
auto useTypeInst = mOrigPropTarget.mType->ToTypeInstance();
auto virtualMethod = (BfMethodInstance*)useTypeInst->mVirtualMethodTable[rawMethodInstance->mVirtualTableIdx].mImplementingMethod;
return mModule->ReferenceExternalMethodInstance(virtualMethod);
}
}
}
if ((mOrigPropTarget) && (mOrigPropTarget.mType != mPropTarget.mType) &&
((!mOrigPropTarget.mType->IsGenericParam()) && (mPropTarget.mType->IsInterface())))

View file

@ -10224,6 +10224,7 @@ BfTypedValue BfModule::Cast(BfAstNode* srcNode, const BfTypedValue& typedVal, Bf
if (!castedElementVal)
return BfTypedValue();
auto fieldRef = mBfIRBuilder->CreateInBoundsGEP(curTupleValue, 0, toFieldInstance->mDataIdx);
castedElementVal = LoadValue(castedElementVal);
mBfIRBuilder->CreateStore(castedElementVal.mValue, fieldRef);
}
else