From 36bc70aaee4f6e3efb1caa3e461c90076fc50ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Wed, 15 Jul 2020 14:23:39 +0200 Subject: [PATCH] [poincare/power] Better Power::shallowReduce Take care of an undefined index that arrived during the remove unit --- poincare/src/power.cpp | 4 ++-- poincare/test/simplification.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/poincare/src/power.cpp b/poincare/src/power.cpp index 299221d86..dab4c6707 100644 --- a/poincare/src/power.cpp +++ b/poincare/src/power.cpp @@ -407,8 +407,8 @@ Expression Power::shallowReduce(ExpressionNode::ReductionContext reductionContex { Expression indexUnit; index = index.removeUnit(&indexUnit); - if (!indexUnit.isUninitialized()) { - // There must be no unit in the exponent + if (!indexUnit.isUninitialized() || index.isUndefined()) { + // There must be no unit nor undefined in the exponent return replaceWithUndefinedInPlace(); } assert(index == childAtIndex(1)); diff --git a/poincare/test/simplification.cpp b/poincare/test/simplification.cpp index ffd80f3e4..13860225b 100644 --- a/poincare/test/simplification.cpp +++ b/poincare/test/simplification.cpp @@ -1316,7 +1316,7 @@ QUIZ_CASE(poincare_simplification_user_function_with_convert) { "f", 1, Symbol::Builder('x'))); assert_expression_reduce(e); - assert_reduce("e^(f(0))", Radian, Polar); + assert_parsed_expression_simplify_to("e^(f(0))", "undef"); Ion::Storage::sharedStorage()->recordNamed("f.func").destroy(); }