From 21923058006b688c8b1852108a6de3daf791c6c5 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Tue, 22 Sep 2020 08:34:16 -0700 Subject: [PATCH] Fixed for discriminated unions with attempted initializers --- IDEHelper/Compiler/BfModule.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index f0780129..ed860901 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -3659,8 +3659,8 @@ void BfModule::ResolveConstField(BfTypeInstance* typeInstance, BfFieldInstance* Fail("Const requires initializer", fieldDef->mFieldDeclaration->mNameNode); } } - else - { + else if (mBfIRBuilder != NULL) + { SetAndRestoreValue prevTypeInstance(mCurTypeInstance, typeInstance); SetAndRestoreValue prevIgnoreWrite(mBfIRBuilder->mIgnoreWrites, true); @@ -3692,6 +3692,12 @@ void BfModule::ResolveConstField(BfTypeInstance* typeInstance, BfFieldInstance* constValue = uncastedInitValue.mValue; } + if ((mCurTypeInstance->IsPayloadEnum()) && (fieldDef->IsEnumCaseEntry())) + { + // Illegal + constValue = BfIRValue(); + } + mBfIRBuilder->SetInsertPoint(prevInsertBlock); }