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

オープン
#1,877 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
67/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript
領域
backend, data

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
TypeScript
スター
2.8k
フォーク
175
平均マージ
2日 5時間
マージ済み PR(30日)
23

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

handsontable/hyperformula のほかの issue

handsontable/hyperformula の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。