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:
parent
25a7d5fed1
commit
066a7fce09
1 changed files with 7 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue