sc/source/core/tool/interpr1.cxx |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 1c14b9efb0677dea65ff220222fbb8d5c2aa6973
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Sun Dec 26 15:18:46 2021 +0100
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Sun Dec 26 16:21:28 2021 +0100

    Resolves: tdf#146377 Propagate condition error of IF(condition)
    
    Previsouly a given ELSE-path was executed as the condition is never
    TRUE on error, which wasn't significant unless the ELSE was an
    error evaluating function like IFERROR() or ISERROR() or other
    IS...() functions.
    
    This changes behaviour of an undocumented side effect, so *might*
    break existing expressions that (unwillingly?) relied on it.
    
    Gnumeric, Excel and GoogleSheets all agree on propagating the
    error value as implemented now.
    
    Change-Id: I0905a363be7a3b02925f1c41b4e6c8d36f12df93
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127515
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 345ab7115815..44672395903f 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -187,7 +187,13 @@ void ScInterpreter::ScIfJump()
         break;
         default:
         {
-            if ( GetBool() )
+            const bool bCondition = GetBool();
+            if (nGlobalError != FormulaError::NONE)
+            {   // Propagate error, not THEN- or ELSE-path, jump behind.
+                PushError(nGlobalError);
+                aCode.Jump( pJump[ nJumpCount ], pJump[ nJumpCount ] );
+            }
+            else if ( bCondition )
             {   // TRUE
                 if( nJumpCount >= 2 )
                 {   // THEN path

Reply via email to