1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Fixed const expression crash issue

This commit is contained in:
Brian Fiete 2020-12-25 14:56:57 -08:00
parent 25a7d5fed1
commit 066a7fce09

View file

@ -7918,15 +7918,19 @@ BfTypedValue BfModule::TryLookupGenericConstVaue(BfIdentifierNode* identifierNod
{
BfConstExprValueType* constExprValueType = (BfConstExprValueType*)genericParamResult;
auto constType = genericTypeConstraint;
if (constType == NULL)
constType = GetPrimitiveType(BfTypeCode_IntPtr);
BfExprEvaluator exprEvaluator(this);
exprEvaluator.mExpectingType = genericTypeConstraint;
exprEvaluator.mExpectingType = constType;
exprEvaluator.GetLiteral(identifierNode, constExprValueType->mValue);
if (exprEvaluator.mResult)
{
auto castedVal = CastToValue(identifierNode, exprEvaluator.mResult, genericTypeConstraint, (BfCastFlags)(BfCastFlags_Explicit | BfCastFlags_SilentFail));
auto castedVal = CastToValue(identifierNode, exprEvaluator.mResult, constType, (BfCastFlags)(BfCastFlags_Explicit | BfCastFlags_SilentFail));
if (castedVal)
return BfTypedValue(castedVal, genericTypeConstraint);
return BfTypedValue(castedVal, constType);
}
return exprEvaluator.mResult;