Commit ca0bb89
Add SEQUENCE built-in function (#1645)
## Problem
HyperFormula was missing the SEQUENCE dynamic array function for
generating sequential number arrays.
## Fix
Implements `SEQUENCE(rows, [cols], [start], [step])` as a new
`SequencePlugin`:
- Returns a rows×cols array of sequential numbers, filled row-major
- Parse-time array size prediction via `sequenceArraySize()` — handles
NUMBER and STRING literals; non-literal args (cell refs, formulas)
return `#VALUE!` (architectural limitation: array size must be known at
parse time)
- Error types match Excel: negative dims → `#VALUE!`, zero dims →
`#NUM!` (mapped from Excel's `#CALC!`)
- `emptyAsDefault: true` on optional params — empty args like
`=SEQUENCE(3,,,)` use declared defaults
- i18n for all 17 languages with proper Excel-localized names
## Changed files
| File | Change |
|------|--------|
| `src/interpreter/plugin/SequencePlugin.ts` | New plugin: `sequence()`
+ `sequenceArraySize()` |
| `src/interpreter/plugin/index.ts` | Plugin registration |
| `src/i18n/languages/*.ts` (17 files) | SEQUENCE translations |
| `docs/guide/built-in-functions.md` | SEQUENCE row in Array functions
table |
| `docs/guide/release-notes.md` | Unreleased section |
| `CHANGELOG.md` | Added entry |
| `test/smoke.spec.ts` | 3 smoke tests |
| `test/fetch-tests.sh` | Robustness fix for `git pull` |
## Tests
Regression tests in `handsontable/hyperformula-tests` (branch
`feature/SEQUENCE`):
| Group | Tests | Coverage |
|-------|-------|----------|
| Core sanity | #1–#8 | Basic usage, MS docs examples |
| Default parameters | #9–#13 | Omitted cols/start/step |
| Empty args | #14–#21 | emptyAsDefault behavior |
| Step variants | #22–#28 | Zero, negative, fractional step |
| Truncation | #29–#35 | Fractional dims, trunc-to-zero |
| Error conditions | #36–#48 | Zero/negative dims, text, arity,
propagation |
| Type coercion | #49–#59 | Booleans, strings, cell refs, empty cells |
| Large sequences | #60–#63 | 100×100, 1000×1, 1×1000 |
| Fill order | #64–#69 | Row-major verification |
| Function combos | #70–#74 | SUM, AVERAGE, MAX, MIN, COUNT |
| Behavioral | #75–#80 | Max dims, spill |
| Dynamic args | #81–#82 | Architectural limitation (cell ref → #VALUE!)
|
- 82/82 PASS confirmed in Excel desktop (Microsoft 365)
- 3 smoke tests in `test/smoke.spec.ts`
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Adds a new array-producing built-in (`SEQUENCE`) with parse-time size
prediction rules; mistakes here can affect array vertex creation and
spill/error behavior across formulas. Remaining changes are
documentation/i18n updates plus a minor test script tweak.
>
> **Overview**
> Adds the `SEQUENCE(rows, [cols], [start], [step])` built-in via a new
`SequencePlugin`, generating row-major numeric arrays and enforcing
dimension/max-sheet limits with appropriate errors.
>
> Introduces parse-time result sizing (`sequenceArraySize`) that only
accepts literal `rows`/`cols` (non-literal dimensions now yield
`#VALUE!` due to unknown output size), and wires the plugin into the
interpreter exports.
>
> Updates changelog and docs to list `SEQUENCE`, adds function name
translations across all language packs, and adjusts
`test/fetch-tests.sh` to pull explicitly from `origin` for the current
branch.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
b08cd79. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 04180f8 commit ca0bb89
File tree
23 files changed
+198
-1
lines changed- docs/guide
- src
- i18n/languages
- interpreter/plugin
- test
23 files changed
+198
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
191 | 192 | | |
192 | 193 | | |
193 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
191 | 192 | | |
192 | 193 | | |
193 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
191 | 192 | | |
192 | 193 | | |
193 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
193 | 194 | | |
194 | 195 | | |
195 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
191 | 192 | | |
192 | 193 | | |
193 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
191 | 192 | | |
192 | 193 | | |
193 | 194 | | |
| |||
0 commit comments