mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[poincare/unit] Fix crash with Units in Graph
In Graph, the weak ReductionTarget would cause _X^0 to not be simplified to 1, and would break an assertion in Unit::chooseBestRepresentativeAndPrefix. Change-Id: I8167a472802baf0a73bf48513f492e78517107ef
This commit is contained in:
committed by
Émilie Feral
parent
9be5e7671c
commit
1917999f6d
@@ -687,6 +687,13 @@ static void chooseBestRepresentativeAndPrefixForValueOnSingleUnit(Expression uni
|
||||
factor = factor.childAtIndex(0);
|
||||
}
|
||||
assert(factor.type() == ExpressionNode::Type::Unit);
|
||||
if (exponent == 0.f) {
|
||||
/* Finding the best representative for a unit with exponent 0 doesn't
|
||||
* really make sense, and should only happen with a weak ReductionTarget
|
||||
* (such as in Graph app), that only rely on approximations. We keep the
|
||||
* unit unchanged as it will approximate to undef anyway. */
|
||||
return;
|
||||
}
|
||||
static_cast<Unit &>(factor).chooseBestRepresentativeAndPrefix(value, exponent, reductionContext, optimizePrefix);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user