[poincare/power] Better Power::shallowReduce

Take care of an undefined index that arrived during the remove unit
This commit is contained in:
Léa Saviot
2020-07-15 14:23:39 +02:00
committed by EmilieNumworks
parent 9e94304db0
commit 36bc70aaee
2 changed files with 3 additions and 3 deletions

View File

@@ -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));

View File

@@ -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();
}