Bug 91502 - The functions FORMULA and ISFORMULA do not return the correct array under "iterative evaluation" condition (array-evaluation)
Summary: The functions FORMULA and ISFORMULA do not return the correct array under "it...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: Other All
: medium normal
Assignee: Eike Rathke
URL:
Whiteboard: target:6.2.0 target:6.1.1
Keywords:
Depends on:
Blocks: Calc-Function
  Show dependency treegraph
 
Reported: 2015-05-22 22:22 UTC by Wolfgang Jäger
Modified: 2018-07-27 19:50 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Demonstration of the bug (13.59 KB, application/vnd.oasis.opendocument.spreadsheet)
2015-05-22 22:45 UTC, Wolfgang Jäger
Details
Comparison of matrix evaluation of ISEVEN and ISFORMULA (12.02 KB, application/vnd.oasis.opendocument.spreadsheet)
2016-02-20 10:10 UTC, Christian
Details
Demo by user Christian reworked as descibed in comment #7 (11.51 KB, application/vnd.oasis.opendocument.spreadsheet)
2016-02-20 13:48 UTC, Wolfgang Jäger
Details
Reworked demo containing additional proof for a claim. (12.22 KB, application/vnd.oasis.opendocument.spreadsheet)
2016-08-22 10:09 UTC, Wolfgang Jäger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Jäger 2015-05-22 22:22:16 UTC

    
Comment 1 Wolfgang Jäger 2015-05-22 22:45:57 UTC
Created attachment 115863 [details]
Demonstration of the bug
Comment 2 Wolfgang Jäger 2015-05-22 22:52:06 UTC
Sorry! I exited the description prematurely.
I was stimulated by the thread http://ask.libreoffice.org/en/question/50970/calc-sum-only-numbers-entered-manually-where-isformula-returns-false/ of the official forum to go a bit into details and found:
The FORMULA funvtion and the ISFORMULA function cannot be used with a correct result under conditions where the "iterative" array evaluation should apply or in a "ForceArray" parameter position.
Cf. http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part2.html#__RefHeading__1017866_715980110
See attached demonstration.
Comment 3 raal 2015-05-23 11:07:34 UTC
Reproducible with Version: 5.1.0.0.alpha1+
Build ID: e929194317a7debb1c5467282230cbbabe61a710
TinderBox: Linux-rpm_deb-x86_64@46-TDF, Branch:master, Time: 2015-05-22_06:33:18

Setting to NEW and adding Winfried to CC.

http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part2.html#ISFORMULA
Passing a non-reference, or a reference to more than one cell, is implementation-defined.
Comment 4 Christian 2016-02-20 09:57:29 UTC
Please consider allowing ISFORMULA within Matrix evaluations.
Comment 5 Christian 2016-02-20 10:10:10 UTC
Created attachment 122814 [details]
Comparison of matrix evaluation of ISEVEN and ISFORMULA
Comment 6 Wolfgang Jäger 2016-02-20 13:48:06 UTC
Created attachment 122817 [details]
Demo by user Christian reworked as descibed in comment #7
Comment 7 Wolfgang Jäger 2016-02-20 13:55:23 UTC
Just tested with LibO V5.1.0.3 first using the original attachment to comment #1. The behaviour of FORMULA changed. It now retiurns the expected array of formulas applied under array evaluation. The behaviour of ISFORMULA is unchanged. (Cf comments #4,#5 by user Christian Koppen. I also reworked his example and added a (temporary) workaround concerning his request based on the new behaviour of the FORMULA function. As I still not am fully familiar with this bugzilla software I quoted a wrong number of comment for it.
Comment 8 Christian 2016-02-20 17:40:01 UTC
Wolfgang, I tried your new testcase with LibreOffice 5.0 (don't know the exact version), but unfortunately it didn't work. Then I updated to LibreOffice 5.1.0.3 and now I can confirm your workaround. This will probably help me, thanks a lot.
Comment 9 Wolfgang Jäger 2016-08-22 10:09:55 UTC
Created attachment 126957 [details]
Reworked demo containing additional proof for a claim.

The demo was rework adding columns K through N to the otherwise unchanged sheet. 

This is done to prove the claim that also the FORMULA function is not correctly working in array-context under specific conditions despite the fact that FORMULA is returning the correct array if directly entered for array evaluation using (Ctrl+Shift+Enter).
 
The one "specific condition" demonstrated is the occurrence of FORMULA(A2:A5) as a subformula on the ForceArray parameter position of SUMPRODUCT in cell M1 of the reworked sheet.

Cases where FORMULA and ISFORMULA are used for array evaluation may not be very frequent. However, if used without success, the exploration of the cause of the error may be difficult.
Comment 10 Wolfgang Jäger 2016-12-09 23:57:13 UTC
FORMULA is returning the correct array in my tests under array evaluation since V5.1.1.3 (latest). Insofar: fixed - worksforme.

ISFORMULA is showing the bug as demonstrated earlier still in V5.3.0.0 beta1.
Comment 11 QA Administrators 2018-07-26 02:40:52 UTC Comment hidden (obsolete)
Comment 12 Eike Rathke 2018-07-26 09:51:31 UTC
Taking.
Comment 13 Commit Notification 2018-07-27 08:48:08 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a44d1b8d47e0ef6645c7c5def1fe5d34d470ae0b

Resolves: tdf#91502 handle ISFORMULA() in array context

It will be available in 6.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 14 Commit Notification 2018-07-27 08:49:32 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=2008a520e429bc2581001d61b63ff934c2255be0

Related: tdf#91502 handle FORMULA() pCur->IsInForceArray() as well

It will be available in 6.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 15 Commit Notification 2018-07-27 08:50:55 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=0d9f755fec6f29b72e9e4d110da3175ade46588c

Introduce and use ScInterpreter::IsInArrayContext(), tdf#91502 follow-up

It will be available in 6.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 16 Eike Rathke 2018-07-27 08:52:30 UTC
Pending review for 6-1
https://gerrit.libreoffice.org/58174
https://gerrit.libreoffice.org/58175
Comment 17 Commit Notification 2018-07-27 19:50:41 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f3b221773c9a1afb88d4675c303f0f03a7ccaaea&h=libreoffice-6-1

Resolves: tdf#91502 handle ISFORMULA() in array context

It will be available in 6.1.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 18 Commit Notification 2018-07-27 19:50:51 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=c20eb29560fa9d9e552c799203156c0742451eba&h=libreoffice-6-1

Related: tdf#91502 handle FORMULA() pCur->IsInForceArray() as well

It will be available in 6.1.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.