Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fixed a cell holding a static error value — a formula the parser rejected, or an error value entered directly — being reported under the address of whichever cell read it first. Such a cell now reports its own address, and keeps reporting it as rows and columns move around it. After a very long run of structural changes the original position can no longer be reconstructed, and the address is omitted rather than guessed. [#1547](https://github.com/handsontable/hyperformula/issues/1547)
- A parsing error, an error value typed directly into a cell, and an error literal written into a formula are now attributed to `parser`, `user input`, or `literal` respectively, instead of being silently unattributed or (for a parsing error) reporting no address at all. `#SPILL!` errors now report the cell that failed to spill instead of no address. [#1547](https://github.com/handsontable/hyperformula/issues/1547)
- Fixed a function or operator being reported as the producer of an error it only read. A reference that cannot be resolved now reports `reference`, and one destroyed by removing rows or columns reports `removed reference`, so `=SUM(A2:A99999999999)` no longer reports `SUM` and `=ABS(A2:A99999999999)` no longer reports an argument index that belongs to nothing. Errors that arise inside an array are attributed to the operation that built the array, so a broadcast gap in `=INDEX(A1:A2+B1:B3, 3, 1)` now reports the `+` operator rather than `INDEX`, and a per-element coercion failure reports the function alongside the argument index. [#1547](https://github.com/handsontable/hyperformula/issues/1547)
- Reading a formula cell's value before it has been computed now throws a `CellValueNotComputedError` naming the cell's address, instead of a plain `Error` with no way to trace which cell caused it. [#444](https://github.com/handsontable/hyperformula/issues/444)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Changelog missing PR link

Low Severity

The new Unreleased changelog bullet ends with an issue link to #444 rather than a pull-request URL. New engine changelog entries need a [#NNNN](https://github.com/handsontable/hyperformula/pull/NNNN) PR link; an issue-only reference is not a substitute.

Fix in Cursor Fix in Web

Triggered by learned rule: CHANGELOG bullets need a PR link

Reviewed by Cursor Bugbot for commit da37522. Configure here.

- Fixed the `AVERAGEIF` function returning a division-by-zero error when the calculated average was `0`. [#1733](https://github.com/handsontable/hyperformula/pull/1733)
- Fixed the localized names of `VSTACK` and `HSTACK` in 14 language packs to match Microsoft Excel. [#1748](https://github.com/handsontable/hyperformula/pull/1748)
- Fixed the MAXPOOL and MEDIANPOOL functions throwing an uncaught `TypeError` instead of returning the `#VALUE!` error when the range dimensions are not a whole multiple of the window size and the stride. [#1718](https://github.com/handsontable/hyperformula/pull/1718)
Expand Down
5 changes: 3 additions & 2 deletions src/DependencyGraph/FormulaVertex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {ArrayValue, ErroredArray, CellArray, NotComputedArray} from '../ArrayVal
import {CellError, equalSimpleCellAddress, ErrorType, SimpleCellAddress} from '../Cell'
import {RawCellContent} from '../CellContentParser'
import {ErrorMessage} from '../error-message'
import {CellValueNotComputedError} from '../errors'
import {EmptyValue, getRawValue, InternalScalarValue, InterpreterValue} from '../interpreter/InterpreterValue'
import {LazilyTransformingAstService} from '../LazilyTransformingAstService'
import {Maybe} from '../Maybe'
Expand Down Expand Up @@ -136,7 +137,7 @@ export class ArrayFormulaVertex extends FormulaVertex {

getCellValue(): InterpreterValue {
if (this.array instanceof NotComputedArray) {
throw Error('Array not computed yet.')
throw new CellValueNotComputedError(this.cellAddress)
}
return this.array.simpleRangeValue()
}
Expand Down Expand Up @@ -275,7 +276,7 @@ export class ScalarFormulaVertex extends FormulaVertex {
if (this.cachedCellValue !== undefined) {
return this.cachedCellValue
} else {
throw Error('Value of the formula cell is not computed.')
throw new CellValueNotComputedError(this.cellAddress)
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ export class InvalidAddressError extends Error {
}
}

/**
* Error thrown when a formula cell's value is read before it has been computed.
*
* Carries the address as a field, so callers can trace the cell without parsing
* it back out of the message. The missing address was the complaint in issue #444.
* Thrown by both ScalarFormulaVertex and ArrayFormulaVertex.
*/
export class CellValueNotComputedError extends Error {
constructor(public readonly address: SimpleCellAddress) {
super(`Value of the formula cell (sheet = ${address.sheet}, row = ${address.row}, col = ${address.col}) is not computed.`)
}
}

/**
* Error thrown when the given arguments are invalid
*/
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
DenseSparseChooseBasedOnThreshold
} from './DependencyGraph/AddressMapping/ChooseAddressMappingPolicy'
import {
CellValueNotComputedError,
ConfigValueTooBigError,
ConfigValueTooSmallError,
EvaluationSuspendedError,
Expand Down Expand Up @@ -71,6 +72,7 @@ class HyperFormulaNS extends HyperFormula {
public static DetailedCellError = DetailedCellError
public static ExportedCellChange = ExportedCellChange
public static ExportedNamedExpressionChange = ExportedNamedExpressionChange
public static CellValueNotComputedError = CellValueNotComputedError
public static ConfigValueTooBigError = ConfigValueTooBigError
public static ConfigValueTooSmallError = ConfigValueTooSmallError
public static EvaluationSuspendedError = EvaluationSuspendedError
Expand Down Expand Up @@ -154,6 +156,7 @@ export {
ExportedNamedExpressionChange,
DetailedCellError,
CellError,
CellValueNotComputedError,
ConfigValueTooBigError,
ConfigValueTooSmallError,
EvaluationSuspendedError,
Expand Down
Loading