diff --git a/poincare/src/expression.cpp b/poincare/src/expression.cpp index 3b303c09f..9e1008cf0 100644 --- a/poincare/src/expression.cpp +++ b/poincare/src/expression.cpp @@ -126,18 +126,19 @@ void Expression::Simplify(Expression ** expressionAddress, Context & context, An angleUnit = Preferences::sharedPreferences()->angleUnit(); } SimplificationRoot root(*expressionAddress); - root.deepReduce(context, angleUnit); - root.deepBeautify(context, angleUnit); + root.editableOperand(0)->deepReduce(context, angleUnit); + root.editableOperand(0)->deepBeautify(context, angleUnit); *expressionAddress = root.editableOperand(0); } void Expression::Reduce(Expression ** expressionAddress, Context & context, AngleUnit angleUnit) { SimplificationRoot root(*expressionAddress); - root.deepReduce(context, angleUnit); + root.editableOperand(0)->deepReduce(context, angleUnit); *expressionAddress = root.editableOperand(0); } Expression * Expression::deepReduce(Context & context, AngleUnit angleUnit) { + assert(parent() != nullptr); for (int i = 0; i < numberOfOperands(); i++) { if ((editableOperand(i))->deepReduce(context, angleUnit)->type() == Type::Undefined && this->type() != Type::SimplificationRoot) { return replaceWith(new Undefined(), true); @@ -147,6 +148,7 @@ Expression * Expression::deepReduce(Context & context, AngleUnit angleUnit) { } Expression * Expression::deepBeautify(Context & context, AngleUnit angleUnit) { + assert(parent() != nullptr); Expression * e = shallowBeautify(context, angleUnit); for (int i = 0; i < e->numberOfOperands(); i++) { e->editableOperand(i)->deepBeautify(context, angleUnit); diff --git a/poincare/src/hierarchy.cpp b/poincare/src/hierarchy.cpp index f8f6b1426..395ce7091 100644 --- a/poincare/src/hierarchy.cpp +++ b/poincare/src/hierarchy.cpp @@ -44,7 +44,7 @@ void Hierarchy::replaceOperand(const Expression * oldOperand, Expression * newOp Expression ** op = const_cast(operands()); for (int i=0; iparent() == this) { const_cast(oldOperand)->setParent(nullptr); } if (deleteOldOperand) {