Repository navigation
Return #CALC! when TAKE takes nothing and DROP drops everything (HF-134) - #1906
Conversation
…everything (HF-134) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Note
Medium risk: Changes the error value returned by the unreleased TAKE and DROP functions in the interpreter's array plugin, so only a narrow, not-yet-released behaviour path is affected.
Full review: no issues found.
Want a deeper review? Comment /review improve on its own line: a full review of the latest commit with an extra fix-oriented pass (about 2x the cost).
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
hyperformula-docs | 5162784 | Commit Preview URL Branch Preview URL |
Nov 20 2026, 10:22 AM |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1906 +/- ##
========================================
Coverage 97.64% 97.64%
========================================
Files 212 212
Lines 18328 18328
Branches 4292 4291 -1
========================================
Hits 17896 17896
- Misses 424 432 +8
+ Partials 8 0 -8
🚀 New features to boost your workflow:
|
Performance comparison of head (5162784) vs base (16a7649) |
marcin-kordas-hoc
left a comment
There was a problem hiding this comment.
At 5162784 with hyperformula-tests at 5fcf6d9442, function-take.spec.ts and function-drop.spec.ts pass 189/189, 19 tests fail on the develop engine, and putting #N/A back fails 9 tests for TAKE and 10 for DROP. In Excel Online, 16 TAKE and DROP cases (including the description's table, a zero count from a cell and DROP(5,1)) return #CALC! and ERROR.TYPE 14, as here, and ISNA, IFNA and IFERROR around them match too. I checked other functions in 25 cases, and 24 match: the 13 where Excel Online returns #CALC! (FILTER, UNIQUE, SEQUENCE, CONCAT, TEXTJOIN, and an empty FILTER inside VSTACK, HSTACK, SORT, ROWS, INDEX, TAKE and DROP) return it here too, and the 8 zero, empty or out-of-range cases of CHOOSEROWS, CHOOSECOLS, WRAPROWS, WRAPCOLS, EXPAND and TRIMRANGE give Excel's #VALUE!, #NUM! or #REF!. The one difference, =FILTER(A1:C3,{TRUE;FALSE}) (#VALUE! in Excel, #N/A here), is the same on develop. Neither function is in 3.5.0, so no changelog entry or migration-guide row is needed, and both list-of-differences.md rows are gone.
nit: Low severity, high confidence. The JSDoc of dropArraySize() at line 912, outside the diff, still says the formula evaluates to its #N/A error.
Context
#1889 added the
#CALC!error and switched FILTER, UNIQUE, SEQUENCE, CONCAT and TEXTJOIN to it, as Excel does. TAKE and DROP reached develop after that PR was cut, and still returned#N/Awhere Excel returns#CALC!:0,-0,0.5,FALSE(), or both counts 0)Both now return
#CALC!, and the twolist-of-differences.mdrows for this gap are removed. Neither function has been released yet, so no changelog entry is needed.Every other array function on develop was checked against Excel for the same family of cases (zero counts, empty results, nested arrays, an empty array passed through VSTACK, SORT, INDEX, ROWS and others): they already return Excel's error.
How did you test your changes?
npx jestinhyperformula/with the paired branchfix/hf-134-calc-sweep(handsontable/hyperformula-tests#125): 14,882 passed, 3 skipped.npm run lintandnpm run verify:typingspass.AI assistance
Claude Code made the change, updated the specs and measured the cases in Excel.
Compatibility with Excel and Google Sheets
=TAKE(A1:C3, 0),=TAKE(A1:C3, , 0),=TAKE(A1:C3, 0, 0)#CALC!#CALC!(was#N/A)=TAKE(A1:C3, -0),=TAKE(A1:C3, 0.5)#CALC!#CALC!(was#N/A)=DROP(A1:C3, 3),=DROP(A1:C3, -3),=DROP(A1:C3, 5)#CALC!#CALC!(was#N/A)=DROP(A1:C3, , 3),=DROP(A1:C3, 3, 3)#CALC!#CALC!(was#N/A)Public API changes
None.
Out of scope and follow-ups
#CALC!in their own PR (Add TOROW and TOCOL functions (HF-388, HF-387) #1828).Types of changes
Related issues
Checklist
dev-docs/pages this change affects – or none needed it.🤖 Generated with Claude Code