[apps/calculation/additional_outputs] Expression::removeUnit can be

called on reduced expression only
This commit is contained in:
Émilie Feral
2020-06-11 12:02:48 +02:00
parent ad86378a5c
commit a26dc4be79

View File

@@ -80,6 +80,8 @@ void UnitListController::setExpression(Poincare::Expression e) {
}
if (canChangeUnitPrefix) {
Expression newUnits;
// Reduce to be able to removeUnit
PoincareHelpers::Reduce(&m_memoizedExpressions[currentExpressionIndex], App::app()->localContext(), ExpressionNode::ReductionTarget::User);
m_memoizedExpressions[currentExpressionIndex] = m_memoizedExpressions[currentExpressionIndex].removeUnit(&newUnits);
double value = Shared::PoincareHelpers::ApproximateToScalar<double>(m_memoizedExpressions[currentExpressionIndex], App::app()->localContext());
ExpressionNode::ReductionContext reductionContext(