From e1394e2fb7c49f8178ed7f9d19da9d73183da4da Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 21 Jan 2021 04:42:15 -0800 Subject: [PATCH] Fixed variable assignment detection with classes member values --- IDE/Tests/CompileFail001/src/Declarations.bf | 30 ++++++++++++++++++++ IDEHelper/Compiler/BfExprEvaluator.cpp | 11 ++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/IDE/Tests/CompileFail001/src/Declarations.bf b/IDE/Tests/CompileFail001/src/Declarations.bf index d142439b..fa5256c0 100644 --- a/IDE/Tests/CompileFail001/src/Declarations.bf +++ b/IDE/Tests/CompileFail001/src/Declarations.bf @@ -25,5 +25,35 @@ namespace IDETest } } } + + public class ClassD + { + public int mA; + public int mB; + } + + public struct StructA + { + public int32 mA; + public int32 mB; + } + + public struct StructB + { + ClassD parent; + StructA mSA; + int mInnerInt; + + public this(ClassD test) + { + parent = test; + mInnerInt = parent.mA; + + mSA.mA = 123; + int a = mSA.mA; + int b = mSA.mB; //FAIL + mSA.mB = 234; + } + } } } diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index a6d084ea..576c8229 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -603,7 +603,7 @@ bool BfGenericInferContext::InferGenericArguments(BfMethodInstance* methodInstan { InferGenericArgument(methodInstance, srcGenericArg, ifaceConstraint, BfIRValue()); auto typeInstance = srcGenericArg->ToTypeInstance(); - if (typeInstance == NULL) + if ((typeInstance == NULL) && (srcGenericArg->IsWrappableType())) typeInstance = mModule->GetWrappedStructType(srcGenericArg); if (typeInstance != NULL) @@ -4544,9 +4544,12 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar } if ((mResultLocalVar != NULL) && (fieldInstance->mMergedDataIdx != -1)) - { - fieldInstance->GetDataRange(mResultLocalVarField, mResultLocalVarFieldCount); - mResultLocalVarRefNode = targetSrc; + { + if (mResultLocalVarFieldCount != 1) + { + fieldInstance->GetDataRange(mResultLocalVarField, mResultLocalVarFieldCount); + mResultLocalVarRefNode = targetSrc; + } } if ((curCheckType->IsIncomplete()) && (!curCheckType->mNeedsMethodProcessing))