mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Fixed result-of-tuple crash
This commit is contained in:
parent
3863166545
commit
407c742bf9
2 changed files with 19 additions and 8 deletions
|
@ -6428,8 +6428,7 @@ BfTypedValue BfExprEvaluator::CheckEnumCreation(BfAstNode* targetSrc, BfTypeInst
|
||||||
if (argValue)
|
if (argValue)
|
||||||
{
|
{
|
||||||
// argValue can have a value even if tuplePtr does not have a value. This can happen if we are assigning to a (void) tuple,
|
// 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
|
// but we have a value that needs to be attempted to be casted to void
|
||||||
|
|
||||||
argValue = mModule->Cast(argValues.mResolvedArgs[tupleFieldIdx].mExpression, argValue, resolvedFieldType);
|
argValue = mModule->Cast(argValues.mResolvedArgs[tupleFieldIdx].mExpression, argValue, resolvedFieldType);
|
||||||
if (tupleFieldPtr)
|
if (tupleFieldPtr)
|
||||||
{
|
{
|
||||||
|
@ -11415,11 +11414,14 @@ void BfExprEvaluator::Visit(BfLambdaBindExpression* lambdaBindExpr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
capturedValue = capturedTypedVal.mValue;
|
capturedValue = capturedTypedVal.mValue;
|
||||||
|
|
||||||
if (capturedValue)
|
if (capturedValue)
|
||||||
{
|
{
|
||||||
auto fieldPtr = mModule->mBfIRBuilder->CreateInBoundsGEP(mResult.mValue, 0, fieldInstance->mDataIdx);
|
if (!capturedTypedVal.mType->IsVar())
|
||||||
mModule->mBfIRBuilder->CreateStore(capturedValue, fieldPtr);
|
{
|
||||||
|
auto fieldPtr = mModule->mBfIRBuilder->CreateInBoundsGEP(mResult.mValue, 0, fieldInstance->mDataIdx);
|
||||||
|
mModule->mBfIRBuilder->CreateStore(capturedValue, fieldPtr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -14638,9 +14640,17 @@ BfModuleMethodInstance BfExprEvaluator::GetPropertyMethodInstance(BfMethodDef* m
|
||||||
auto propTypeInst = mPropTarget.mType->ToTypeInstance();
|
auto propTypeInst = mPropTarget.mType->ToTypeInstance();
|
||||||
auto rawMethodInstance = mModule->GetRawMethodInstance(propTypeInst, methodDef);
|
auto rawMethodInstance = mModule->GetRawMethodInstance(propTypeInst, methodDef);
|
||||||
|
|
||||||
auto useTypeInst = mOrigPropTarget.mType->ToTypeInstance();
|
BF_ASSERT(rawMethodInstance->mVirtualTableIdx != -1);
|
||||||
auto virtualMethod = (BfMethodInstance*)useTypeInst->mVirtualMethodTable[rawMethodInstance->mVirtualTableIdx].mImplementingMethod;
|
if (rawMethodInstance->mVirtualTableIdx == -1)
|
||||||
return mModule->ReferenceExternalMethodInstance(virtualMethod);
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10224,6 +10224,7 @@ BfTypedValue BfModule::Cast(BfAstNode* srcNode, const BfTypedValue& typedVal, Bf
|
||||||
if (!castedElementVal)
|
if (!castedElementVal)
|
||||||
return BfTypedValue();
|
return BfTypedValue();
|
||||||
auto fieldRef = mBfIRBuilder->CreateInBoundsGEP(curTupleValue, 0, toFieldInstance->mDataIdx);
|
auto fieldRef = mBfIRBuilder->CreateInBoundsGEP(curTupleValue, 0, toFieldInstance->mDataIdx);
|
||||||
|
castedElementVal = LoadValue(castedElementVal);
|
||||||
mBfIRBuilder->CreateStore(castedElementVal.mValue, fieldRef);
|
mBfIRBuilder->CreateStore(castedElementVal.mValue, fieldRef);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue