feat(functions): implement VSTACK and HSTACK (HF-71)#1698
Merged
Conversation
Add the VSTACK and HSTACK array-manipulation functions to ArrayPlugin, mirroring the existing FILTER implementation pattern. - VSTACK stacks input arrays vertically: result height = sum of input heights, width = max input width. Narrower rows are padded on the right with #N/A. - HSTACK stacks input arrays horizontally: result width = sum of input widths, height = max input height. Shorter columns are padded at the bottom with #N/A. - Both are variadic (repeatLastArgs: 1) and accept ranges, array literals and scalars (FunctionArgumentType.RANGE, enableArrayArithmeticForArguments). - Result dimensions are declared at parse time via the sizeOfResultArrayMethod (vstackArraySize / hstackArraySize) so the result spills correctly, consistent with HyperFormula's parse-time array sizing. Padding uses ErrorType.NA (HyperFormula has no #CALC!). - Add translations for all 17 built-in language packs (English name in every locale, matching Excel/Sheets, which do not localize these functions). enUS inherits enGB. - Document both functions in the built-in functions guide and add a changelog entry. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
✅ Deploy Preview for hyperformula-dev-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
Task linked: HF-71 Implement VSTACK and HSTACK functions |
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 4abdae5. Configure here.
Performance comparison of head (3db462b) vs base (92e6c73) |
…(HF-71) HSTACK indexed sourceRow[col] directly, trusting every row to be as wide as the range. A jagged SimpleRangeValue (a row shorter than range.width(), reachable via a custom function) produced an empty cell where VSTACK produces #N/A. Reuse padRowToWidth so both functions pad identically. Reported by Cursor Bugbot on PR #1698. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…-71) - Add JSDoc to the new vstackArraySize/hstackArraySize/stackSubChecks/ padRowToWidth methods (sequba: JSDoc required on new public surface). - HSTACK pads rows inline with an index guard instead of building an intermediate padded array via padRowToWidth, avoiding a per-row slice + spread allocation in the common rectangular path. Behaviour is unchanged (covered by the jagged-input and empty-array regression tests); VSTACK keeps padRowToWidth, whose copy it relies on per result row. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
sequba
approved these changes
Jul 14, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1698 +/- ##
===========================================
- Coverage 97.15% 96.70% -0.46%
===========================================
Files 176 176
Lines 15404 15450 +46
Branches 3409 3417 +8
===========================================
- Hits 14966 14941 -25
- Misses 438 509 +71
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
Implements two new array-spilling functions,
VSTACKandHSTACK, inArrayPlugin.#N/A.#N/A.Behaviour matches Excel 365 / Google Sheets, with the documented HyperFormula nuances below.
Scope
src/interpreter/plugin/ArrayPlugin.ts—VSTACK/HSTACKmetadata, methods, and*ArraySizeparse-time size calculations (sharedstackSubCheckshelper;VSTACKaligns each row viapadRowToWidth,HSTACKpads inline).src/i18n/languages/*.ts— function-name entries for all 18 language packs (enUSinherits fromenGB). The names are identical across locales, matching Excel's convention for these functions.docs/guide/built-in-functions.md— entries for both functions.CHANGELOG.md—Addedentry under[Unreleased].HyperFormula nuances vs. Excel
null) rather than coercing to0. HyperFormula preserves the empty value; Excel (which has no empty-result cell) displays0. The stacked structure is identical.runFunction-based function behaves (e.g.ABS,FILTER). Errors located inside an input range pass through per cell, preserving their type (matches Excel).Test coverage
Unit tests live in the private tests repository: handsontable/hyperformula-tests#18 (57 cases: 28 VSTACK + 29 HSTACK), mirroring a validated Excel 365 oracle. They cover same-width/height stacks, dimension mismatch with
#N/Apadding, scalars, single-arg passthrough, mixed types, error passthrough, empty cells, jagged input from a custom function, empty-array error propagation, nestedVSTACK/HSTACK, and integration withSEQUENCE/TRANSPOSE.🤖 Generated with Claude Code
Note
Low Risk
Additive array functions in an isolated plugin with no changes to core engine, auth, or persistence; behavior is covered by external oracle tests.
Overview
Adds VSTACK and HSTACK as new array-spilling functions in
ArrayPlugin, aligned with Excel 365 / Google Sheets.VSTACK concatenates ranges vertically (height = sum of input heights, width = max width); narrower rows get
#N/Apadding on the right viapadRowToWidth. HSTACK concatenates horizontally (width = sum of widths, height = max height); shorter inputs get#N/Aat the bottom. Both use variadicRANGEarguments (repeatLastArgs: 1), array arithmetic on arguments, and paired*ArraySizemethods for spill sizing; sharedstackSubChecksresolves per-argument dimensions at parse time.Documentation and localization are updated:
built-in-functions.md,CHANGELOG.mdunder Unreleased, andVSTACK/HSTACKentries in all 18 language packs (names kept asVSTACK/HSTACKlike Excel).Reviewed by Cursor Bugbot for commit 3db462b. Bugbot is set up for automated code reviews on this repo. Configure here.