Bug 68235 - evaluateInternal(ValueEval,ValueEval,int,int)@IfError does not handle missing arguments
Summary: evaluateInternal(ValueEval,ValueEval,int,int)@IfError does not handle missing...
Status: NEEDINFO
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: 5.3.x-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-27 02:41 UTC by zhonghao
Modified: 2023-11-27 10:32 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zhonghao 2023-11-27 02:41:12 UTC
The code is as follows:

private static ValueEval EvaluateInternal(ValueEval arg, ValueEval iferror, int srcCellRow, int srcCellCol)
        {
            arg = WorkbookEvaluator.DereferenceResult(arg, srcCellRow, srcCellCol);
            if (arg is ErrorEval)
            {
               return iferror;
            }
            else
            {
                return arg;
            }
        }

NOPI programmers complain that the above code does not handle missing arguments:

https://github.com/nissl-lab/npoi/commit/fa5aab30649ac3344dad34216062cf4dac49efeb

Their fixed code is as follows:

private static ValueEval EvaluateInternal(ValueEval arg, ValueEval iferror, int...

 if (arg is ErrorEval)
            {
                return iferror;
                //if the 2nd argument is missing, use an empty string as default
                if (iferror is MissingArgEval)
                {
                    return new StringEval(string.Empty);
                }
                else
                {
                    return iferror;
                }
            }...
}
Comment 1 PJ Fanning 2023-11-27 10:32:31 UTC
We are not going to just copy NPOI. Please provide real world examples. POI is a volunteer project and it is normally best to provide a patch with a test case yourself.