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 17:47:42 +0100
commit439814c48b3194398e7abe97a855193dc3e28f12 (patch)
tree21ed16b282e91db1391ea3323a93df631f80a354
parent5abdeb97d14a956b152ff7c08add9f313d554358 (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 (cherry picked from commit 1c14b9efb0677dea65ff220222fbb8d5c2aa6973) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127481
-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