pjfanning opened a new pull request, #1301: URL: https://github.com/apache/poi/pull/1301
Fixes https://bz.apache.org/bugzilla/show_bug.cgi?id=55747 (and the duplicate https://bz.apache.org/bugzilla/show_bug.cgi?id=55324). ### Problem `IF`'s 2nd and 3rd parameters are declared as `R` class in `functionMetadata.txt`. When one of those arguments is a "simple value function" (all-`V` params, `V` return: `MID`, `CONCATENATE`, `ISBLANK`, `REPLACE`, ...), the shortcut path in `OperandClassTransformer` passed the caller's desired class (`R`) straight down to the function's operands. So `A1` in `IF(A1<>"",MID(A1,1,2),"X")` was serialised as an `R` `RefPtg` and Excel shows `#VALUE!` for the cell until the formula is re-entered (F2, Enter). This matches the BiffViewer diff attached to the bug (`RefPtg [A1]R` in the POI file vs `[A1]V` in the Excel-resaved file). ### Fix In the simple-value-function path, a plain reference operand now gets `V` when the caller asked for `R`. Nested *functions* keep receiving the caller's class - mapping `R`→`V` for every child broke the Excel-sourced `TestRVA` case `COUNT(ABS(FREQUENCY(...)))`, where Excel keeps `FREQUENCY` as `A`. ### Tests - `TestFormulaEvaluatorBugs.test55747_55324`: enabled the six `// FIXME!` assertions that have been commented out since 2015, changed the E1 false-route expectation from `R` to `V` (Excel tolerates `R` in a branch it never evaluates, but `V` is what `MID` wants and what Excel writes for the evaluated branch), and added the exact formula from the bug report (`IF(ISBLANK(A1),"blank",CONCATENATE(A1," - %s."))`). - Also dropped the stale `TODO Fix this...` from `IfFunc`'s javadoc. - Full `:poi:test` suite passes locally (7389 tests). 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
