[Bug]: An array literal that starts with a spilled range changes that range's stored values

Aperta
#1,877 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
67/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
backend, data

Direzione di ricerca

Start with the array evaluation path in Interpreter.ts at the reported ARRAY branch and ArrayValue.ts where raw() exposes row arrays. Reproduce the example from the issue and trace how a range matching a spilled result is used while building the literal. Done means the literal copies the rows it builds from, the spill result stays unchanged on recalculation, and the reported formulas return the expected values.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Bug
Description

When the first element in a row of an array literal is a range that exactly matches another formula's spilled result, the literal appends the row's other elements to that formula's stored result. The cells still show the right values, but formulas that read the range as an array get wrong results:

const hf = HyperFormula.buildFromArray([
  ['=SEQUENCE(2)', 10, '=SUM({A1:A2,B1:B2})', '=SUMPRODUCT(A1:A2,A1:A2)'],
  [null, 20],
], {licenseKey: 'gpl-v3'})

hf.getCellValue({sheet: 0, col: 3, row: 0}) // 505, expected 5
hf.getCellValue({sheet: 0, col: 2, row: 0}) // 33, correct
// A1:A2 still show 1 and 2

With plain values 1 and 2 in A1:A2, D1 returns 5. In Microsoft Excel Online, =SUMPRODUCT(A1:A2,A1:A2) over =SEQUENCE(2) returns 5. (Excel doesn't accept references inside array constants, so the literal itself can't be compared.)

If the literal's formula is recalculated, for example because it also contains RAND(), the stored result gains another column every time.

Cause: a range that matches a spilled result is evaluated through ArrayValue.raw(), which returns the result's own row arrays (Interpreter.ts:213 and :222, ArrayValue.ts:132-134). The ARRAY branch of Interpreter.evaluateAst then pushes the next elements into those rows (Interpreter.ts:266 and :269).

Expected: the array literal copies the rows it builds from, and the other formula's result stays unchanged.

Video or screenshots

N/A

Demo

Code snippet in the description.

HyperFormula version

3.5.0 (also develop at ec7512d21)

Your framework

None (Node.js)

Your environment

Node.js 22.23.4 on Linux

Lingua principale
TypeScript
Stelle
2.8k
Fork
175
Merge medio
2g 5h
PR unite (30g)
23

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di handsontable/hyperformula

Tutte le issue di handsontable/hyperformula

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.