Skip to content

Return #CALC! when TAKE takes nothing and DROP drops everything (HF-134) - #1906

Merged
Tobiadefami merged 1 commit into
developfrom
fix/hf-134-calc-sweep
Nov 20, 2026
Merged

Tobiadefami merged 1 commit into
developfrom
fix/hf-134-calc-sweep

Conversation

@Tobiadefami

Copy link
Copy Markdown
Collaborator

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/A where Excel returns #CALC!:

  • TAKE with a row or column count that truncates to 0 (0, -0, 0.5, FALSE(), or both counts 0)
  • DROP that drops every row or every column (including counts larger than the source)

Both now return #CALC!, and the two list-of-differences.md rows 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 jest in hyperformula/ with the paired branch fix/hf-134-calc-sweep (handsontable/hyperformula-tests#125): 14,882 passed, 3 skipped.
  • The 19 updated TAKE and DROP specs fail on develop and pass here.
  • npm run lint and npm run verify:typings pass.

AI assistance

Claude Code made the change, updated the specs and measured the cases in Excel.

Compatibility with Excel and Google Sheets

Formula Excel Google Sheets HyperFormula
=TAKE(A1:C3, 0), =TAKE(A1:C3, , 0), =TAKE(A1:C3, 0, 0) #CALC! No such function #CALC! (was #N/A)
=TAKE(A1:C3, -0), =TAKE(A1:C3, 0.5) #CALC! No such function #CALC! (was #N/A)
=DROP(A1:C3, 3), =DROP(A1:C3, -3), =DROP(A1:C3, 5) #CALC! No such function #CALC! (was #N/A)
=DROP(A1:C3, , 3), =DROP(A1:C3, 3, 3) #CALC! No such function #CALC! (was #N/A)

Public API changes

None.

Out of scope and follow-ups

Types of changes

  • Breaking change (existing functionality no longer works as before) – agreed with the maintainers
  • New feature or improvement (a non-breaking change that adds functionality)
  • Bug fix (a non-breaking change that fixes an issue)
  • Additional language file, or a change to an existing language file (translations)
  • Change to the documentation

Related issues

  1. HF-134 (follow-up to Add the #CALC! error type (HF-134) #1889)
  2. Tests: handsontable/hyperformula-tests#125

Checklist

🤖 Generated with Claude Code

…everything (HF-134)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@handsontable-pr-review handsontable-pr-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.64%. Comparing base (16a7649) to head (5162784).

Additional details and impacted files

Impacted file tree graph

@@           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     
Files with missing lines Coverage Δ
hyperformula/src/interpreter/plugin/ArrayPlugin.ts 99.39% <100.00%> (ø)

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Performance comparison of head (5162784) vs base (16a7649)

                                     testName |    base |    head | change
--------------------------------------------------------------------------
                                      Sheet A |  503.18 |   502.6 | -0.12%
                                      Sheet B |  158.87 |  162.29 | +2.15%
                                      Sheet T |  143.66 |  143.17 | -0.34%
                                Column ranges |  479.99 |  485.59 | +1.17%
                                Sorted lookup | 15355.9 | 15408.2 | +0.34%
Sheet A:  change value, add/remove row/column |   16.06 |    17.2 | +7.10%
 Sheet B: change value, add/remove row/column |  132.09 |  136.76 | +3.54%
                   Column ranges - add column |   155.7 |   157.9 | +1.41%
                Column ranges - without batch |  470.86 |  464.88 | -1.27%
                        Column ranges - batch |  115.21 |  113.61 | -1.39%

@marcin-kordas-hoc marcin-kordas-hoc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Tobiadefami
Tobiadefami merged commit 576d838 into develop Nov 20, 2026
36 checks passed
@Tobiadefami
Tobiadefami deleted the fix/hf-134-calc-sweep branch November 20, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants