Skip to content
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2fa0930
Fix HF-361: empty string no longer coerces to 0
marcin-kordas-hoc Sep 10, 2026
78b1c75
HF-361: complete the Definition of Done for the empty-string change
marcin-kordas-hoc Sep 10, 2026
c99427b
HF-361: correct the scope of the change in the changelog and migratio…
marcin-kordas-hoc Sep 10, 2026
a24a523
HF-361: look through parentheses when checking for a reference in num…
marcin-kordas-hoc Sep 22, 2026
23fb194
docs: shorten the changelog entry to one sentence
marcin-kordas-hoc Oct 22, 2026
159f352
Merge develop into fix/hf-361-empty-string-coercion
marcin-kordas-hoc Oct 22, 2026
731a20f
HF-361: Describe the parenthesized-reference change in the changelog …
marcin-kordas-hoc Oct 23, 2026
761251f
HF-361: Write TRUE() in the migration guide's IF examples, which Hype…
marcin-kordas-hoc Oct 23, 2026
cc66c2a
HF-361: Keep only Excel values that were measured in the migration guide
marcin-kordas-hoc Oct 23, 2026
40d669e
Merge develop into fix/hf-361-empty-string-coercion
marcin-kordas-hoc Oct 30, 2026
4c96a66
List the text-only array argument among the differences from Excel
marcin-kordas-hoc Oct 30, 2026
8bc9db8
HF-361: Ship the empty-string change as a fix: move the entry to Fixe…
marcin-kordas-hoc Nov 3, 2026
d476660
HF-361: Say in the types-of-values guide that an empty string is Text…
marcin-kordas-hoc Nov 3, 2026
8b624ed
Merge branch 'develop' into fix/hf-361-empty-string-coercion
marcin-kordas-hoc Nov 3, 2026
299f1b2
Merge branch 'develop' into fix/hf-361-empty-string-coercion
marcin-kordas-hoc Nov 3, 2026
c3e9ff8
Merge branch 'develop' into fix/hf-361-empty-string-coercion
marcin-kordas-hoc Nov 4, 2026
42b44ec
Merge branch 'develop' into fix/hf-361-empty-string-coercion
marcin-kordas-hoc Nov 12, 2026
fe2b028
HF-361: State what coerceNonDateScalarToMaybeNumber returns for a bla…
marcin-kordas-hoc Nov 12, 2026
3219161
HF-361: List text returned by INDEX, CHOOSE, IF or a name among the d…
marcin-kordas-hoc Nov 12, 2026
19eeb5b
HF-361: Ignore text read through INDEX, CHOOSE, IF or a name in aggre…
marcin-kordas-hoc Nov 15, 2026
05f0a52
HF-361: Order the Unreleased changelog sections as Keep a Changelog does
marcin-kordas-hoc Nov 15, 2026
2061f15
HF-361: Check the built-in plugin only for INDEX, IF and CHOOSE argum…
marcin-kordas-hoc Nov 15, 2026
7afdb57
HF-361: Read IF and CHOOSE by the argument they returned in aggregations
marcin-kordas-hoc Nov 16, 2026
afb1cfb
HF-361: Read IFS and SWITCH by the argument they returned in aggregat…
marcin-kordas-hoc Nov 16, 2026
4c7d42f
Merge branch 'develop' into fix/hf-361-empty-string-coercion
marcin-kordas-hoc Nov 18, 2026
aff4073
Merge branch 'develop' into fix/hf-361-empty-string-coercion
marcin-kordas-hoc Nov 18, 2026
4618450
Merge remote-tracking branch 'origin/develop' into fix/hf-361-empty-s…
marcin-kordas-hoc Nov 19, 2026
0dcb986
Read XLOOKUP results and IF or CHOOSE ranges as references in numeric…
marcin-kordas-hoc Nov 19, 2026
6af2f10
Merge branch 'develop' into fix/hf-361-empty-string-coercion
marcin-kordas-hoc Nov 19, 2026
2f86335
Merge branch 'develop' into fix/hf-361-empty-string-coercion
marcin-kordas-hoc Nov 19, 2026
c4c3ad8
Remove the RANK.EQ empty-string rows from the list of differences
marcin-kordas-hoc Nov 19, 2026
4ded7b8
Merge branch 'develop' into fix/hf-361-empty-string-coercion
marcin-kordas-hoc Nov 19, 2026
f494586
Merge branch 'develop' into fix/hf-361-empty-string-coercion
Tobiadefami Nov 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fixed functions such as `MATCH`, `INDEX` and `COUNTIF` throwing an uncaught `Unknown array` error when they read a range that exactly matches the area of an array formula returning an error, for example `=MATCH(2, B1:B3, 0)` next to `=SORT(A1:A3)` whose source contains `#DIV/0!`. They now read the range cell by cell. [#1876](https://github.com/handsontable/hyperformula/pull/1876)
- Fixed unbounded parser cache growth in long-running instances that process many distinct formulas, including when undo is disabled. [#1635](https://github.com/handsontable/hyperformula/issues/1635)
- Fixed array formulas spilling past the `maxRows` and `maxColumns` limits: they now return `#SPILL!` when their result extends beyond the sheet edge. [#1774](https://github.com/handsontable/hyperformula/pull/1774)
- Fixed numeric contexts reading an empty string (`""`) as `0` instead of as text (e.g. `=""+0` now returns `#VALUE!` instead of `0`), and numeric aggregations treating a parenthesized reference such as `(A1)` differently from `A1`. [#1768](https://github.com/handsontable/hyperformula/pull/1768)
- Fixed numeric aggregations such as `SUM`, `AVERAGE` and `MAX` reading a cell reached through `INDEX`, `CHOOSE`, `IF`, `IFS`, `SWITCH`, `XLOOKUP` or a named expression as a value: as with a direct reference, its text, booleans and blanks are now ignored. [#1768](https://github.com/handsontable/hyperformula/pull/1768)
- Fixed the `ADDRESS` function adding the sheet separator (`!`) when the `sheetName` argument is an empty argument slot (e.g. `=ADDRESS(2,3,1,FALSE(),)` now returns `R2C3` instead of `!R2C3`), while an explicit `""` still adds it. [#1641](https://github.com/handsontable/hyperformula/issues/1641)

## [3.5.0] - 2026-10-09
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/list-of-differences.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Very large or very small input scales can also cause substantial differences in
| Named expression names | ProductPrice1:=42 | A name must be distinctive from a cell reference (case-insensitive), so `ProductPrice1` is invalid. See [complete naming rules](named-expressions.md#name-rules). | A name that is a valid cell reference is allowed if the column address is at least 4-letter long, so `ProductPrice1` is valid. | A name that is a valid cell reference is allowed if the column address is at least 4-letter long, so `ProductPrice1` is valid. |
| Applying a scalar value to a function taking range | COLUMNS(A1) | `CellRangeExpected` error. | Treats the element as length-1 range. Returns 1 for the example. | Same as Google Sheets. |
| Coercion of explicit arguments | VARP(2, 3, 4, TRUE(), FALSE(), "1",) | 1.9592, based on the behavior of Microsoft Excel. | GoogleSheets implementation is not consistent with the standard (see also `VAR.S`, `STDEV.P`, and `STDEV.S` function.) | 1.9592 |
| Empty text used as a number | =""+1<br><br>=ABS("")<br><br>=SEQUENCE("") | Empty text is converted to `0`: the examples return `1`, `0` and `#CALC!` (`SEQUENCE` with 0 rows). | Not checked. | `#VALUE!` for all three examples. |
| Ranges created with `:` | A1:A2<br><br>A$1:$A$2<br><br>A:C<br><br>1:2<br><br>Sheet1!A1:A2 | Allowed ranges consist of two addresses (A1:B5), columns (A:C) or rows (3:5).<br>They cannot be mixed or contain named expressions. | Everything allowed. | Same as Google Sheets. |
| Formatting inside the TEXT function | TEXT(A1,"dd-mm-yy")<br><br>TEXT(A1,"###.###”) | To support all date, time and currency formats, set [`stringifyDateTime`](compatibility-with-microsoft-excel.md#date-and-time-formats) and [`stringifyCurrency`](currency-handling.md) configuration options. | A wide variety of options for string formatting is supported. | Same as Google Sheets. |
| Cell references inside inline arrays | ={A1, A2} | The array's value is calculated but not updated when the cells' values change. | The array's value is calculated and updated when the cells' values change. | ERROR: invalid array |
Expand All @@ -50,6 +49,7 @@ Very large or very small input scales can also cause substantial differences in
| Booleans converted to text | =CONCAT(TRUE())<br><br>=VALUETOTEXT(FALSE())<br><br>=TRUE()&"" | `TRUE` and `FALSE` in every language, in `CONCAT`, `CONCATENATE`, `TEXTJOIN`, `VALUETOTEXT` and `&`. | Not checked. | The boolean names of the Excel language, for example `PRAWDA` and `FAŁSZ` in Polish. |
| Array size limits | =SUM(VSTACK(SEQUENCE(1048576), SEQUENCE(1))) | An array computed inside a formula is not limited in either dimension, so the example returns the sum when [`maxRows`](../api/interfaces/configparams.md#maxrows) is at least 1,048,576. With the default `maxRows` (40,000), `SEQUENCE(1048576)` returns `#VALUE!`, because `SEQUENCE` is limited by the `maxRows` and [`maxColumns`](../api/interfaces/configparams.md#maxcolumns) configuration options. | In-memory arrays are not limited in either dimension. Returns `549756338177`. | In-memory arrays are limited to 1,048,576 rows and 1,048,576 columns. Returns `#NUM!`. |
| FILTER and UNIQUE near the sheet edge | =FILTER(A1:A10, A1:A10>8)<br>in the second-to-last row, where A1:A10 = 1 to 10 | Returns `#SPILL!`: the area reserved for the result has the height of the source, and it does not fit before the sheet edge. See [Known limitations](known-limitations.md). | Not checked. | Spills `9` and `10` into the last two rows. |
| Text-only array argument in numeric aggregations | B1: =SUM(IF(A1:A3>0,"",A1:A3))<br>where A1:A3 = 1, 2, 3<br><br>=COUNT(IF({1,0},"",5)) | With the [array arithmetic mode](arrays.md#array-arithmetic-mode) disabled (the default), `IF` returns a single value, here the empty string, which is text: `SUM` returns `#VALUE!` and `COUNT` returns `0`. With the mode enabled, `IF` returns an array, and the results are `0` and `1`. | Not checked. | `IF` returns an array, and the aggregations ignore the text in it: `SUM` returns `0` and `COUNT` returns `1`. |
| TYPE of ROW or COLUMN in an expression | =TYPE(ROW(A1:A2)+0) | `ROW` over more than one row and `COLUMN` over more than one column count as arrays only when passed to `TYPE` directly, so the example gives `1`. | Not checked. | Returns `64`. |
| TYPE of a one-by-one array | =TYPE({1}+0)<br>=TYPE(IF(TRUE(), {1}))<br>=TYPE(VSTACK(A1))<br>where A1 holds an error | An array that holds a single value counts as an array (`64`) only when it is the argument itself: an array constant, a call to a function that returns arrays, such as `FILTER`, `SEQUENCE` or `VSTACK`, or `TRANSPOSE` of such an array. Passed through an operator or another function first, it is reduced to its value, so the first two examples give `1`. When such a function call has an error as its single value, `TYPE` gives `16`, as in the third example. | Not checked. | Returns `64` for all three examples. |
| ERROR.TYPE function | =ERROR.TYPE(#NULL!)<br>=ERROR.TYPE(#GETTING_DATA) | HyperFormula has no `#NULL!` or `#GETTING_DATA` error, so the codes 1 and 8 are never returned and the literals do not parse. `#CYCLE!`, `#ERROR!` and `#LIC!`, which are HyperFormula's own errors, have no code and give `#N/A`. | Not checked. | Returns `1` for `#NULL!` and `8` for `#GETTING_DATA`. |
Expand Down
2 changes: 2 additions & 0 deletions docs/guide/types-of-values.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ When you pass JavaScript values directly (not as strings):
- `Date` object → **Date/DateTime type** (converted to internal numeric representation)
- `null` or `undefined` → **Empty cell**

To empty a cell, pass `null`, not an empty string: `''` is stored as Text, so `=A1+1` returns `#VALUE!` when `A1` holds it.

```js
const hf = HyperFormula.buildFromArray([
[42], // Number
Expand Down
11 changes: 7 additions & 4 deletions hyperformula/src/interpreter/ArithmeticHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,17 @@ export class ArithmeticHelper {
)
}

/**
* Coerces a scalar value to a number for use in arithmetic and numeric aggregation, without
* attempting date-string parsing (see {@link coerceToMaybeNumber} for that extra step).
*
* A blank cell (`EmptyValue`) reads as `0`. An empty string is text, so like any non-numeric
* string it returns `undefined`.
*/
public coerceNonDateScalarToMaybeNumber(arg: InternalScalarValue): Maybe<ExtendedNumber> {
if (arg === EmptyValue) {
return 0
Comment thread
marcin-kordas-hoc marked this conversation as resolved.
Resolved
} else if (typeof arg === 'string') {
if (arg === '') {
return 0
}

const maybePercentNumber = this.coerceStringToMaybePercentNumber(arg)
if (maybePercentNumber !== undefined) {
return maybePercentNumber
Expand Down
65 changes: 59 additions & 6 deletions hyperformula/src/interpreter/plugin/BooleanPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

import {CellError, ErrorType} from '../../Cell'
import {ErrorMessage} from '../../error-message'
import {ProcedureAst} from '../../parser'
import {Ast, ProcedureAst} from '../../parser'
import {InterpreterState} from '../InterpreterState'
import {InternalNoErrorScalarValue, InternalScalarValue, InterpreterValue} from '../InterpreterValue'
import {FunctionArgumentType, FunctionPlugin, FunctionPluginTypecheck, ImplementedFunctions} from './FunctionPlugin'
import {SimpleRangeValue} from '../../SimpleRangeValue'
import {FunctionArgumentType, FunctionMetadata, FunctionPlugin, FunctionPluginTypecheck, ImplementedFunctions} from './FunctionPlugin'
import {forgetSelectedArgument, recordSelectedArgument} from './SelectedArgument'

/**
* Interpreter plugin containing boolean functions
Expand Down Expand Up @@ -102,6 +104,11 @@ export class BooleanPlugin extends FunctionPlugin implements FunctionPluginTypec
},
}

/**
* The values of the arguments that {@link evaluateArguments} evaluated last.
*/
private lastEvaluatedArguments: InterpreterValue[] = []

/**
* Corresponds to TRUE()
*
Expand Down Expand Up @@ -135,9 +142,12 @@ export class BooleanPlugin extends FunctionPlugin implements FunctionPluginTypec
* @param state
*/
public conditionalIf(ast: ProcedureAst, state: InterpreterState): InterpreterValue {
return this.runFunction(ast.args, state, this.metadata('IF'), (condition, arg2, arg3) => {
forgetSelectedArgument(ast)
const result = this.runFunction(ast.args, state, this.metadata('IF'), (condition, arg2, arg3) => {
recordSelectedArgument(ast, condition ? 1 : 2)
return condition ? arg2 : arg3
})
return this.keepSelectionOnlyForScalarSelectors(ast, result, [0])
}

/**
Expand All @@ -147,14 +157,17 @@ export class BooleanPlugin extends FunctionPlugin implements FunctionPluginTypec
* @param state
*/
public ifs(ast: ProcedureAst, state: InterpreterState): InterpreterValue {
return this.runFunction(ast.args, state, this.metadata('IFS'), (...args) => {
forgetSelectedArgument(ast)
const result = this.runFunction(ast.args, state, this.metadata('IFS'), (...args) => {
for (let idx = 0; idx < args.length; idx += 2) {
if (args[idx]) {
recordSelectedArgument(ast, idx + 1)
return args[idx+1]
}
}
return new CellError(ErrorType.NA, ErrorMessage.NoConditionMet)
})
return this.keepSelectionOnlyForScalarSelectors(ast, result, ast.args.map((_, i) => i).filter(i => i % 2 === 0))
}

/**
Expand Down Expand Up @@ -202,23 +215,27 @@ export class BooleanPlugin extends FunctionPlugin implements FunctionPluginTypec
}

public switch(ast: ProcedureAst, state: InterpreterState): InterpreterValue {
return this.runFunction(ast.args, state, this.metadata('SWITCH'), (selector, ...args) => {
forgetSelectedArgument(ast)
const result = this.runFunction(ast.args, state, this.metadata('SWITCH'), (selector, ...args) => {
const n = args.length
let i = 0
for (; i + 1 < n; i += 2) {
if (args[i] instanceof CellError) {
continue
}
if (this.arithmeticHelper.eq(selector, args[i] as InternalNoErrorScalarValue)) {
recordSelectedArgument(ast, i + 2)
return args[i + 1]
}
}
if (i < n) {
recordSelectedArgument(ast, i + 1)
return args[i]
} else {
return new CellError(ErrorType.NA, ErrorMessage.NoDefault)
}
})
return this.keepSelectionOnlyForScalarSelectors(ast, result, ast.args.map((_, i) => i).filter(i => i === 0 || (i % 2 === 1 && i + 1 < ast.args.length)))
}

public iferror(ast: ProcedureAst, state: InterpreterState): InterpreterValue {
Expand All @@ -242,11 +259,47 @@ export class BooleanPlugin extends FunctionPlugin implements FunctionPluginTypec
}

public choose(ast: ProcedureAst, state: InterpreterState): InterpreterValue {
return this.runFunction(ast.args, state, this.metadata('CHOOSE'), (selector, ...args) => {
forgetSelectedArgument(ast)
const result = this.runFunction(ast.args, state, this.metadata('CHOOSE'), (selector: number, ...args) => {
if (selector > args.length) {
return new CellError(ErrorType.NUM, ErrorMessage.Selector)
}
recordSelectedArgument(ast, selector)
return args[selector - 1]
})
return this.keepSelectionOnlyForScalarSelectors(ast, result, [0])
}

/**
* Evaluates the arguments as {@link FunctionPlugin} does, and keeps their values until the call that evaluated
* them has finished, so that `IF`, `IFS`, `SWITCH` and `CHOOSE` can tell which of them were arrays without
* evaluating them again.
*
* @param {Ast[]} args - the arguments of the call
* @param {InterpreterState} state - interpreter state
* @param {FunctionMetadata} metadata - metadata of the function
* @returns {[InterpreterValue, boolean, boolean][]} what {@link FunctionPlugin} returns
*/
protected evaluateArguments(args: Ast[], state: InterpreterState, metadata: FunctionMetadata): [InterpreterValue, boolean, boolean][] {
const evaluated = super.evaluateArguments(args, state, metadata)
this.lastEvaluatedArguments = evaluated.map(([value]) => value)
return evaluated
}

/**
* Removes the record of a call that returned an array built cell by cell, where each cell can come from a
* different argument: one whose condition, selector or case value is an array. An array returned from a single
* argument, such as `IF(TRUE(), A1:A3)` in array arithmetic mode, keeps the record of that argument.
*
* @param {ProcedureAst} ast - the call, just evaluated
* @param {InterpreterValue} result - what the call returned
* @param {number[]} selectingPositions - the positions in `ast.args` of the condition, selector and case values
* @returns {InterpreterValue} `result`, unchanged
*/
private keepSelectionOnlyForScalarSelectors(ast: ProcedureAst, result: InterpreterValue, selectingPositions: number[]): InterpreterValue {
if (result instanceof SimpleRangeValue && selectingPositions.some(i => this.lastEvaluatedArguments[i] instanceof SimpleRangeValue)) {
forgetSelectedArgument(ast)
}
return result
}
}
Loading
Loading