From affd740ff474218cb0bd259ea02e036742b4966f Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Tue, 20 Oct 2020 06:44:06 -0700 Subject: [PATCH] Field lambda name collision inside field ctor with multiple ctors --- IDEHelper/Compiler/BfExprEvaluator.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 704cfbd4..a09b97ef 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -11549,12 +11549,15 @@ BfLambdaInstance* BfExprEvaluator::GetLambdaInstance(BfLambdaBindExpression* lam methodDef->mName.RemoveToEnd(prevSepPos); } -// if (closureTypeInst != NULL) -// { -// StringT<128> typeInstName; -// BfMangler::Mangle(typeInstName,mModule->mCompiler->GetMangleKind(), closureTypeInst); -// closureHashCtx.MixinStr(typeInstName); -// } + // Mix in this because this can be emitted multiple times when there's multiple ctors and field initializers with lambdas + if (mModule->mCurMethodInstance->mMethodDef->mMethodType == BfMethodType_Ctor) + { + if (auto ctorDecl = BfNodeDynCast(mModule->mCurMethodInstance->mMethodDef->mMethodDeclaration)) + { + if (ctorDecl->mThisToken != NULL) + closureHashCtx.Mixin(ctorDecl->mThisToken->GetStartCharId()); + } + } auto checkMethodState = mModule->mCurMethodState; while (checkMethodState != NULL)