From 994640df1162ef36280fb43576b0b14b626519e4 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 23 Oct 2020 09:03:19 -0700 Subject: [PATCH] Fixed field initialization in structs with extensions --- IDEHelper/Compiler/BfModule.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index e118be87..acdffee0 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -15556,7 +15556,7 @@ void BfModule::EmitCtorBody(bool& skipBody) calledCtorNoBody = true; } - } + } } // Initialize fields (if applicable) @@ -15568,7 +15568,7 @@ void BfModule::EmitCtorBody(bool& skipBody) { // Field initializers occur in CtorNoBody methods for extensions } - else if ((!hadThisInitializer) && (!calledCtorNoBody)) + else if (!hadThisInitializer) { // If we had a 'this' initializer, that other ctor will have initialized our fields @@ -15578,6 +15578,10 @@ void BfModule::EmitCtorBody(bool& skipBody) (mCompiler->mResolvePassData->mAutoComplete == NULL) || (mCompiler->mResolvePassData->mAutoComplete->mResolveType == BfResolveType_ShowFileSymbolReferences)) { + // If we calledCtorNoBody then we did the field initializer code, but we still need to run though it here + // to properly set the assigned flags + SetAndRestoreValue prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, mBfIRBuilder->mIgnoreWrites || calledCtorNoBody); + bool hadInlineInitBlock = false; BfScopeData scopeData;