From b5ddc1c24b149d5bdee9cc5ca1fd959384582be1 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 31 Mar 2022 11:16:13 -0700 Subject: [PATCH] Fixed comptime valueless ctor --- IDEHelper/Compiler/CeMachine.cpp | 12 ++++++------ IDEHelper/Tests/src/ConstEval.bf | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/IDEHelper/Compiler/CeMachine.cpp b/IDEHelper/Compiler/CeMachine.cpp index 876063f9..1953460c 100644 --- a/IDEHelper/Compiler/CeMachine.cpp +++ b/IDEHelper/Compiler/CeMachine.cpp @@ -5149,14 +5149,14 @@ BfTypedValue CeContext::Call(CeCallSource callSource, BfModule* module, BfMethod Fail("Failed to encode return argument"); } } - else if (returnType->IsComposite()) + else if ((methodInstance->mMethodDef->mMethodType == BfMethodType_Ctor) && (thisType != NULL) && (thisType->IsValuelessType())) + { + returnValue = BfTypedValue(module->mBfIRBuilder->CreateConstAggZero(module->mBfIRBuilder->MapType(returnType, BfIRPopulateType_Identity)), thisType); + } + else if ((returnType->IsComposite()) || (returnType->IsValuelessType())) { returnValue = BfTypedValue(module->mBfIRBuilder->CreateConstAggZero(module->mBfIRBuilder->MapType(returnType, BfIRPopulateType_Identity)), returnType); - } - else if (returnType->IsValuelessType()) - { - returnValue = BfTypedValue(module->mBfIRBuilder->GetFakeVal(), returnType); - } + } } mCallStack.Clear(); diff --git a/IDEHelper/Tests/src/ConstEval.bf b/IDEHelper/Tests/src/ConstEval.bf index 3dc1f3d9..e8d07f76 100644 --- a/IDEHelper/Tests/src/ConstEval.bf +++ b/IDEHelper/Tests/src/ConstEval.bf @@ -32,6 +32,12 @@ namespace Tests } } + struct ZeroStruct + { + public this() { } + public const ZeroStruct ConstValue = ZeroStruct(); + } + const String cStrA = "Abc"; const String cStrB = GetStringA(cStrA, 12, 23);