@@ -48,7 +48,6 @@ import {
4848 getBlockChildCount ,
4949 getBlockChildAt ,
5050 getBlockName ,
51- getLocalSetValue ,
5251 getGlobalGetName ,
5352 isGlobalMutable ,
5453 getSideEffects ,
@@ -9231,11 +9230,12 @@ export class Compiler extends DiagnosticEmitter {
92319230 let flow = this . currentFlow ;
92329231
92339232 // make a getter for the expression (also obtains the type)
9234- let getValue = this . compileExpression ( // reports
9233+ const getValueOrigin = this . compileExpression ( // reports
92359234 expression . operand ,
92369235 contextualType . exceptVoid ,
92379236 Constraints . None
92389237 ) ;
9238+ let getValue : ExpressionRef ;
92399239
92409240 // if the value isn't dropped, a temp. local is required to remember the original value,
92419241 // except if a static overload is found, which reverses the use of a temp. (see below)
@@ -9244,24 +9244,25 @@ export class Compiler extends DiagnosticEmitter {
92449244 tempLocal = flow . getTempLocal ( this . currentType ) ;
92459245 getValue = module . local_tee (
92469246 tempLocal . index ,
9247- getValue ,
9247+ getValueOrigin ,
92489248 this . currentType . isManaged
92499249 ) ;
9250+ } else {
9251+ getValue = getValueOrigin ;
92509252 }
92519253
92529254 let expr : ExpressionRef ;
92539255
92549256 switch ( expression . operator ) {
92559257 case Token . Plus_Plus : {
9256-
92579258 // check operator overload
92589259 let classReference = this . currentType . getClassOrWrapper ( this . program ) ;
92599260 if ( classReference ) {
92609261 let overload = classReference . lookupOverload ( OperatorKind . PostfixInc ) ;
92619262 if ( overload ) {
92629263 let isInstance = overload . is ( CommonFlags . Instance ) ;
92639264 if ( tempLocal && ! isInstance ) { // revert: static overload simply returns
9264- getValue = getLocalSetValue ( getValue ) ;
9265+ getValue = getValueOrigin ;
92659266 tempLocal = null ;
92669267 }
92679268 expr = this . compileUnaryOverload ( overload , expression . operand , getValue , expression ) ;
@@ -9337,19 +9338,18 @@ export class Compiler extends DiagnosticEmitter {
93379338 break ;
93389339 }
93399340 case Token . Minus_Minus : {
9340-
93419341 // check operator overload
93429342 let classReference = this . currentType . getClassOrWrapper ( this . program ) ;
93439343 if ( classReference ) {
93449344 let overload = classReference . lookupOverload ( OperatorKind . PostfixDec ) ;
93459345 if ( overload ) {
93469346 let isInstance = overload . is ( CommonFlags . Instance ) ;
93479347 if ( tempLocal && ! isInstance ) { // revert: static overload simply returns
9348- getValue = getLocalSetValue ( getValue ) ;
9348+ getValue = getValueOrigin ;
93499349 tempLocal = null ;
93509350 }
93519351 expr = this . compileUnaryOverload ( overload , expression . operand , getValue , expression ) ;
9352- if ( overload . is ( CommonFlags . Instance ) ) break ;
9352+ if ( isInstance ) break ;
93539353 return expr ; // here
93549354 }
93559355 }
0 commit comments