Allow VLOOKUP over IF array tables#1677
Conversation
✅ Deploy Preview for hyperformula-dev-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for hyperformula-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
ad1405b to
349df04
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 349df04. Configure here.
| return new CellError(ErrorType.VALUE, ErrorMessage.LessThanOne) | ||
| } | ||
|
|
||
| if (index > range.width()) { |
There was a problem hiding this comment.
Lookup accepts scalar table
Low Severity
Removing the range === undefined guard lets VLOOKUP and HLOOKUP run on 1×1 ad-hoc tables from coerceToRange when the second argument is a scalar. Excel returns #VALUE! for a non-table lookup range; these formulas may return a value instead.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 349df04. Configure here.


Context
VLOOKUPandHLOOKUPshould accept lookup tables produced by formulas, not only tables backed by a cell range.For example, Microsoft Excel evaluates this formula to
200:=VLOOKUP(BF109,IF({1,0},BD109:BD112,AV109:AV112),2,0)HyperFormula previously returned
#VALUE!because lookup validation rejected array-backedSimpleRangeValues.How did you test your changes?
VLOOKUPover anIF-constructed array table.npm run test:jest -- smoke.npm run verify:typings.npm run lint.Related issues:
N/A
Checklist:
Note
Medium Risk
Changes evaluation/vectorization behavior of
IFand relaxesVLOOKUP/HLOOKUPvalidation to accept ad-hoc (formula-produced) ranges, which could affect array semantics and error cases for these core functions.Overview
Lookup functions now accept formula-produced array tables (e.g.
IF(...)returning an ad-hocSimpleRangeValue) instead of rejecting them with#VALUE!, by removing the requirement that the lookup table be backed by a concrete cellrangeand validatingindexagainstrangeValuedimensions.IFis updated to vectorize when its condition evaluates to a multi-element ad-hoc range, enabling formulas like=VLOOKUP(key,IF({1,0},rangeA,rangeB),...)to produce a usable lookup table. A smoke regression test and changelog entry were added for this behavior.Reviewed by Cursor Bugbot for commit 349df04. Bugbot is set up for automated code reviews on this repo. Configure here.