From d6c7b2b1ac3a5dc4cc3c15f90e240f3bf3a5c6ea Mon Sep 17 00:00:00 2001 From: Gabriel Ozouf Date: Mon, 31 Aug 2020 11:43:42 +0200 Subject: [PATCH] [poincare/multiplication] Factoring undef power When factoring 1^inf * 1^-inf with Multiplication::factorizeBase, an Undef factor would appear an be carried into the reduced multiplication. We escape early in this situation by returning Undef. Change-Id: Id826ad3cc131349e5bb460f7a8c82fe606294b97 --- poincare/src/multiplication.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/poincare/src/multiplication.cpp b/poincare/src/multiplication.cpp index 3a6f8e9e1..9db2b6c43 100644 --- a/poincare/src/multiplication.cpp +++ b/poincare/src/multiplication.cpp @@ -731,6 +731,11 @@ Expression Multiplication::privateShallowReduce(ExpressionNode::ReductionContext } if (shouldFactorizeBase) { factorizeBase(i, i+1, reductionContext); + /* An undef term could have appeared when factorizing 1^inf and 1^-inf + * for instance. In that case, we escape and return undef. */ + if (childAtIndex(i).isUndefined()) { + return replaceWithUndefinedInPlace(); + } continue; } } else if (TermHasNumeralBase(oi) && TermHasNumeralBase(oi1) && TermsHaveIdenticalExponent(oi, oi1)) {