Related: tdf#111675 Clear global error for arguments if possible
... i.e. if the last result / current stack value is svError
already (usually is nowadays in case of error) and error
evaluating functions may be pending.
Change-Id: I36fc0f169d36dfa7007e8bd3a5c368ed2bb3c919
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131405
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
(cherry picked from commit efb713febeaaf3e4b17886d405d46845d4a0e676)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131363
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index bc99592..1a0eed8 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4540,6 +4540,18 @@ StackVar ScInterpreter::Interpret()
}
if ( nErrorFunction >= nErrorFunctionCount )
++nErrorFunction; // that's it, error => terminate
else if (nErrorFunctionCount && sp && GetStackType() == svError)
{
// Clear global error if we have an individual error result, so
// an error evaluating function can receive multiple arguments
// and not all evaluated arguments inheriting the error.
// This is important for at least IFS() and SWITCH() as long as
// they are classified as error evaluating functions and not
// implemented as short-cutting jump code paths, but also for
// more than one evaluated argument to AGGREGATE() or COUNT()
// that may ignore errors.
nGlobalError = FormulaError::NONE;
}
}
}