astashov / liftosaur

Weightlifting tracker app for coders
https://www.liftosaur.com
GNU Affero General Public License v3.0
241 stars 32 forks source link

Exception that should never happen happened #111

Closed Logan-Dang closed 2 months ago

Logan-Dang commented 3 months ago

image

Line of code causing the issue:

var.totalrm1 += calculate1RM(weights[var.i], completedReps[var.i])

context:

    var.totalrm1 = 0
    for (var.i in weights) {
      var.totalrm1 += calculate1RM(weights[var.i], completedReps[var.i])
    }

happening in the playground

Logan-Dang commented 3 months ago

This works though:

var.totalrm = 0
for (var.i in weights) {
  var.setrm = calculate1RM(weights[var.i], completedReps[var.i])
  var.totalrm = var.totalrm + var.setrm
}
Logan-Dang commented 3 months ago

I see, there is no support for temporary variables getting the inc expression as of right now

if (
  stateVar == null ||
  stateVar.type.name !== NodeName.StateVariable && stateVar.type.name !== NodeName.VariableExpression) ||
  expression == null ||
  incAssignmentExpr == null
  ) {
  assert(NodeName.IncAssignmentExpression);
}