From 1efd403472e01cd155d15714970274b1bacbad22 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Mon, 30 Nov 2020 06:23:52 -0800 Subject: [PATCH] Fixed invalid enum const type finalization with non-enum-case const --- IDEHelper/Compiler/BfModuleTypeUtils.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index 0be4bee9..8d7bd98b 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -3800,12 +3800,13 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy for (auto& fieldInstanceRef : typeInstance->mFieldInstances) { auto fieldInstance = &fieldInstanceRef; - if (fieldInstance->mConstIdx != -1) - { - auto constant = typeInstance->mConstHolder->GetConstantById(fieldInstance->mConstIdx); - BfIRValue newConstant = typeInstance->mConstHolder->CreateConst(typeCode, constant->mUInt64); - fieldInstance->mConstIdx = newConstant.mId; - } + if (fieldInstance->mConstIdx == -1) + continue; + if (!fieldInstance->GetFieldDef()->IsEnumCaseEntry()) + continue; + auto constant = typeInstance->mConstHolder->GetConstantById(fieldInstance->mConstIdx); + BfIRValue newConstant = typeInstance->mConstHolder->CreateConst(typeCode, constant->mUInt64); + fieldInstance->mConstIdx = newConstant.mId; } }