Skip to content

Commit

Permalink
Fix icsharpcode#1447: Assertion on `numeric.compound.add.old(..., ldc…
Browse files Browse the repository at this point in the history
….i8 1)`
  • Loading branch information
dgrunwald committed Mar 15, 2019
1 parent 0d85642 commit f7f6572
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,14 +1326,11 @@ protected internal override TranslatedExpression VisitNumericCompoundAssign(Nume
TranslatedExpression HandleCompoundAssignment(NumericCompoundAssign inst, AssignmentOperatorType op)
{
var target = Translate(inst.Target);
var value = Translate(inst.Value);
value = PrepareArithmeticArgument(value, inst.RightInputType, inst.Sign, inst.IsLifted);


TranslatedExpression resultExpr;
if (inst.CompoundAssignmentType == CompoundAssignmentType.EvaluatesToOldValue) {
Debug.Assert(op == AssignmentOperatorType.Add || op == AssignmentOperatorType.Subtract);
Debug.Assert(value.ResolveResult.IsCompileTimeConstant && 1.Equals(value.ResolveResult.ConstantValue));
Debug.Assert(inst.Value.MatchLdcI(1));
UnaryOperatorType unary;
ExpressionType exprType;
if (op == AssignmentOperatorType.Add) {
Expand All @@ -1347,6 +1344,8 @@ TranslatedExpression HandleCompoundAssignment(NumericCompoundAssign inst, Assign
.WithILInstruction(inst)
.WithRR(new OperatorResolveResult(target.Type, exprType, target.ResolveResult));
} else {
var value = Translate(inst.Value);
value = PrepareArithmeticArgument(value, inst.RightInputType, inst.Sign, inst.IsLifted);
switch (op) {
case AssignmentOperatorType.Add:
case AssignmentOperatorType.Subtract:
Expand Down

0 comments on commit f7f6572

Please sign in to comment.