Bug 64459 - Wrong IF behavior in array formulas
Summary: Wrong IF behavior in array formulas
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 minor (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-20 12:22 UTC by Miłosz Rembisz
Modified: 2020-05-20 12:22 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Miłosz Rembisz 2020-05-20 12:22:00 UTC
I have a simple formula: 'IF(FALSE(),#VALUE!,1)'

Naturally, this formula should always return 1, but when I put it as array formula, it returns '#VALUE!'.

This is due to this part: https://github.com/apache/poi/blob/REL_4_1_2/src/java/org/apache/poi/ss/formula/functions/IfFunc.java#L185

This piece of code is invoked only in array context and it specifies that if second argument (value returned if condition is true) is of type ErrorEval, it is returned regardless of the condition result.

I believe this is wrong and error should be returned only if condition evaluates to true - but this is based only on this simple example. Are there some other use cases that make this piece of code actually viable?