sc/source/core/tool/interpr4.cxx |   12 ++++++++++++
 1 file changed, 12 insertions(+)

New commits:
commit efb713febeaaf3e4b17886d405d46845d4a0e676
Author:     Eike Rathke <[email protected]>
AuthorDate: Fri Mar 11 21:44:21 2022 +0100
Commit:     Eike Rathke <[email protected]>
CommitDate: Sat Mar 12 12:18:30 2022 +0100

    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 <[email protected]>
    Tested-by: Jenkins

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 11353a6e447a..9baa251b08ba 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4541,6 +4541,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;
+            }
         }
     }
 

Reply via email to