@@ -48,7 +48,6 @@ import {
48
48
getBlockChildCount ,
49
49
getBlockChildAt ,
50
50
getBlockName ,
51
- getLocalSetValue ,
52
51
getGlobalGetName ,
53
52
isGlobalMutable ,
54
53
getSideEffects ,
@@ -9231,11 +9230,12 @@ export class Compiler extends DiagnosticEmitter {
9231
9230
let flow = this . currentFlow ;
9232
9231
9233
9232
// make a getter for the expression (also obtains the type)
9234
- let getValue = this . compileExpression ( // reports
9233
+ const getValueOrigin = this . compileExpression ( // reports
9235
9234
expression . operand ,
9236
9235
contextualType . exceptVoid ,
9237
9236
Constraints . None
9238
9237
) ;
9238
+ let getValue : ExpressionRef ;
9239
9239
9240
9240
// if the value isn't dropped, a temp. local is required to remember the original value,
9241
9241
// 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 {
9244
9244
tempLocal = flow . getTempLocal ( this . currentType ) ;
9245
9245
getValue = module . local_tee (
9246
9246
tempLocal . index ,
9247
- getValue ,
9247
+ getValueOrigin ,
9248
9248
this . currentType . isManaged
9249
9249
) ;
9250
+ } else {
9251
+ getValue = getValueOrigin ;
9250
9252
}
9251
9253
9252
9254
let expr : ExpressionRef ;
9253
9255
9254
9256
switch ( expression . operator ) {
9255
9257
case Token . Plus_Plus : {
9256
-
9257
9258
// check operator overload
9258
9259
let classReference = this . currentType . getClassOrWrapper ( this . program ) ;
9259
9260
if ( classReference ) {
9260
9261
let overload = classReference . lookupOverload ( OperatorKind . PostfixInc ) ;
9261
9262
if ( overload ) {
9262
9263
let isInstance = overload . is ( CommonFlags . Instance ) ;
9263
9264
if ( tempLocal && ! isInstance ) { // revert: static overload simply returns
9264
- getValue = getLocalSetValue ( getValue ) ;
9265
+ getValue = getValueOrigin ;
9265
9266
tempLocal = null ;
9266
9267
}
9267
9268
expr = this . compileUnaryOverload ( overload , expression . operand , getValue , expression ) ;
@@ -9337,19 +9338,18 @@ export class Compiler extends DiagnosticEmitter {
9337
9338
break ;
9338
9339
}
9339
9340
case Token . Minus_Minus : {
9340
-
9341
9341
// check operator overload
9342
9342
let classReference = this . currentType . getClassOrWrapper ( this . program ) ;
9343
9343
if ( classReference ) {
9344
9344
let overload = classReference . lookupOverload ( OperatorKind . PostfixDec ) ;
9345
9345
if ( overload ) {
9346
9346
let isInstance = overload . is ( CommonFlags . Instance ) ;
9347
9347
if ( tempLocal && ! isInstance ) { // revert: static overload simply returns
9348
- getValue = getLocalSetValue ( getValue ) ;
9348
+ getValue = getValueOrigin ;
9349
9349
tempLocal = null ;
9350
9350
}
9351
9351
expr = this . compileUnaryOverload ( overload , expression . operand , getValue , expression ) ;
9352
- if ( overload . is ( CommonFlags . Instance ) ) break ;
9352
+ if ( isInstance ) break ;
9353
9353
return expr ; // here
9354
9354
}
9355
9355
}
0 commit comments