summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2021-12-26 15:18:46 +0100
committerEike Rathke <erack@redhat.com>2021-12-26 16:21:28 +0100
commit1c14b9efb0677dea65ff220222fbb8d5c2aa6973 (patch)
treec95592a006ef9c00a7d903d4f2e046be933467b8
parent16506994ecef4bd800575beb9f2b66eb16d902fa (diff)
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 <erack@redhat.com> Tested-by: Jenkins
-rw-r--r--sc/source/core/tool/interpr1.cxx8
1 files changed, 7 insertions, 1 deletions
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