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

Fixed on-demand constraint check crash

This commit is contained in:
Brian Fiete 2020-06-21 10:12:42 -07:00
parent 85279be033
commit d56af187ca

View file

@ -204,6 +204,10 @@ bool BfModule::ValidateGenericConstraints(BfTypeReference* typeRef, BfTypeInstan
return true;
}
// We don't validate constraints for things like Tuples/Delegates
if (genericTypeInst->IsOnDemand())
return true;
SetAndRestoreValue<bool> prevIgnoreErrors(mIgnoreErrors, mIgnoreErrors || ignoreErrors);
genericTypeInst->mGenericTypeInfo->mValidatedGenericConstraints = true;
@ -8851,9 +8855,14 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
}
}
if (matches)
{
typedVal = MakeAddressable(typedVal);
if (resultFlags != NULL)
*resultFlags = (BfCastResultFlags)(BfCastResultFlags_IsAddr);
return mBfIRBuilder->CreateBitCast(typedVal.mValue, mBfIRBuilder->MapType(toType));
}
}
}
// ref int <-> ref int64/int32 (of same size)
if (((fromInner->IsInteger()) && (toInner->IsInteger())) &&
@ -10252,6 +10261,12 @@ BfTypedValue BfModule::Cast(BfAstNode* srcNode, const BfTypedValue& typedVal, Bf
{
return BfTypedValue(mBfIRBuilder->CreateBitCast(typedVal.mValue, mBfIRBuilder->MapTypeInstPtr(tupleType)), tupleType, BfTypedValueKind_ReadOnlyAddr);
}
else if (typedVal.IsSplat())
{
BfTypedValue retTypedValue = typedVal;
retTypedValue.mType = tupleType;
return retTypedValue;
}
BfIRValue curTupleValue = CreateAlloca(tupleType);
auto loadedVal = LoadValue(typedVal);