diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 2e1ea34f..0ceb9136 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -21396,6 +21396,22 @@ void BfExprEvaluator::PerformUnaryOperation_OnResult(BfExpression* unaryOpExpr, } } + switch (unaryOp) + { + case BfUnaryOp_PostIncrement: + case BfUnaryOp_Increment: + case BfUnaryOp_PostDecrement: + case BfUnaryOp_Decrement: + { + if (mResult.mKind == BfTypedValueKind_CopyOnMutateAddr) + { + // Support this ops on direct auto-property access without a copy + mResult.mKind = BfTypedValueKind_Addr; + } + } + break; + } + bool numericFail = false; switch (unaryOp) { @@ -21579,7 +21595,7 @@ void BfExprEvaluator::PerformUnaryOperation_OnResult(BfExpression* unaryOpExpr, break; case BfUnaryOp_PostIncrement: case BfUnaryOp_Increment: - { + { CheckResultForReading(mResult); auto ptr = mResult; //if ((propDef == NULL) && (!mModule->CheckModifyValue(ptr, opToken))) diff --git a/IDEHelper/Tests/src/Properties.bf b/IDEHelper/Tests/src/Properties.bf index df120820..29388a38 100644 --- a/IDEHelper/Tests/src/Properties.bf +++ b/IDEHelper/Tests/src/Properties.bf @@ -10,6 +10,8 @@ namespace Tests { public int mA = 111; + public static int sAutoProp { get; set; } + public this() { } @@ -18,6 +20,17 @@ namespace Tests { mA = a; } + + public static void IncAutoProp() + { + Test.Assert(sAutoProp == 0); + int v = ++sAutoProp; + Test.Assert(v == 1); + Test.Assert(sAutoProp == 1); + int v2 = sAutoProp++; + Test.Assert(v == 1); + Test.Assert(sAutoProp == 2); + } } struct StructB @@ -157,6 +170,13 @@ namespace Tests MethodC(ce); Test.Assert(ce.Val == 999); Test.Assert(MethodD(ce) == 999); + + StructA.IncAutoProp(); + int ap = ++StructA.sAutoProp; + Test.Assert(ap == 3); + int ap2 = StructA.sAutoProp++; + Test.Assert(ap2 == 3); + Test.Assert(StructA.sAutoProp == 4); } } }