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

Improved string-to-sized-array casts and initializations

This commit is contained in:
Brian Fiete 2022-09-05 06:28:23 -07:00
parent 1320b495d2
commit c6f2798db7
4 changed files with 55 additions and 1 deletions

View file

@ -3942,9 +3942,11 @@ void BfExprEvaluator::GetLiteral(BfAstNode* refNode, const BfVariant& variant)
if ((mExpectingType != NULL) && (mExpectingType->IsSizedArray()))
{
auto sizedArray = (BfSizedArrayType*)mExpectingType;
if (sizedArray->mElementType == mModule->GetPrimitiveType(BfTypeCode_Char8))
{
if (sizedArray->IsUndefSizedArray())
sizedArray = mModule->CreateSizedArrayType(sizedArray->mElementType, variant.mString->GetLength());
if (variant.mString->GetLength() > sizedArray->mElementCount)
{
mModule->Fail(StrFormat("String literal is too long to fit into '%s'", mModule->TypeToString(sizedArray).c_str()), refNode);