View Issue Details

IDProjectCategoryView StatusLast Update
0037106FPCPackagespublic2020-05-18 19:19
ReporterPeter Weyrich Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
PlatformLaptopOSWindows 
Summary0037106: fpexprpars IFx-Expression leads to an exception although the branch would not have to be evaluated at all.
DescriptionIf one executes IFF (i = 0,0.0,1.0 / i) and i is zero, then an exception is thrown (division by zero), although that is exactly what the IFF is supposed to catch.
Additional InformationThe IFx expressions should only evaluate the branches if they also apply.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Michael Van Canneyt

2020-05-18 19:19

administrator   ~0122906

IFF is not the IFF you have in excel. It stands for IF with Float value - it returns a float result.
The IFD (If with DateTime) ,IFI (If with Integer) ,IFS (if with string) etc.
are regular functions that evaluate all arguments like actual functions in pascal.
They are old functions introduced when the expression parser was just written.

Since then if() was added to the expression evaluator at a lower level. Long story short:

IF(i = 0,0.0,1.0 / i)

will work as you expect.

Issue History

Date Modified Username Field Change
2020-05-18 18:45 Peter Weyrich New Issue
2020-05-18 19:19 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-05-18 19:19 Michael Van Canneyt Status new => resolved
2020-05-18 19:19 Michael Van Canneyt Resolution open => no change required
2020-05-18 19:19 Michael Van Canneyt FPCTarget => -
2020-05-18 19:19 Michael Van Canneyt Note Added: 0122906