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

Fixed const string bitcast failure

This commit is contained in:
Brian Fiete 2024-12-02 08:28:24 -05:00
parent 03987ba8f5
commit 3864a8896b
3 changed files with 32 additions and 2 deletions

View file

@ -184,7 +184,13 @@ BfTypedValue BfConstResolver::Resolve(BfExpression* expr, BfType* wantType, BfCo
if (isConst)
{
auto constant = mModule->mBfIRBuilder->GetConstant(mResult.mValue);
if ((constant->mConstType == BfConstType_GlobalVar) && ((flags & BfConstResolveFlag_AllowGlobalVariable) == 0))
if ((constant->mTypeCode != BfTypeCode_StringId) && (mModule->HasStringId(mResult.mValue, mModule->mBfIRBuilder)))
{
mModule->Fail("Invalid usage of string constant", expr);
mResult = BfTypedValue();
}
else if ((constant->mConstType == BfConstType_GlobalVar) && ((flags & BfConstResolveFlag_AllowGlobalVariable) == 0))
{
int stringId = mModule->GetStringPoolIdx(mResult.mValue, mModule->mBfIRBuilder);
if (stringId != -1)
@ -193,7 +199,7 @@ BfTypedValue BfConstResolver::Resolve(BfExpression* expr, BfType* wantType, BfCo
}
else
isConst = false;
}
}
}
if ((!isConst) && ((mBfEvalExprFlags & BfEvalExprFlags_AllowNonConst) == 0))