[global_context.cpp] Fixing sequence bug

u(n+2) = u(n+1) + u(n) + u(2)
u(0) = 2
u(1) = 2
Crashed because the global context was not checking if the sequence was
badly referencing itself

Change-Id: I97f694955e15518bb088db50deb761d7ee09d75f
This commit is contained in:
Arthur Camouseigt
2020-09-24 15:40:37 +02:00
committed by Émilie Feral
parent d5ce234d4d
commit 6a84ba2523

View File

@@ -127,7 +127,7 @@ const Expression GlobalContext::ExpressionForSequence(const SymbolAbstract & sym
char unknownN[bufferSize];
Poincare::SerializationHelper::CodePoint(unknownN, bufferSize, UCodePointUnknown);
float rank = symbol.childAtIndex(0).approximateWithValueForSymbol<float>(unknownN, unknownSymbolValue, ctx, Preferences::sharedPreferences()->complexFormat(),Preferences::sharedPreferences()->angleUnit());
if (std::floor(rank) == rank) {
if (std::floor(rank) == rank && !seq.badlyReferencesItself(ctx)) {
SequenceContext sqctx(ctx, sequenceStore());
return Float<double>::Builder(seq.evaluateXYAtParameter(rank, &sqctx).x2());
} else {