Skip to content

Uncaught "Resizing to smaller array" when a spilling VSTACK/HSTACK/array literal contains an element whose size depends on a cell #1780

Description

@marcin-kordas-hoc

HyperFormula.buildFromArray([['=VSTACK(SEQUENCE(B1),SEQUENCE(2))', 2]], {licenseKey: 'gpl-v3'}) throws Error: Resizing to smaller array instead of spilling 1,2,1,2. Same for =HSTACK(SEQUENCE(1,B1),SEQUENCE(1,2)), ={SEQUENCE(B1);1} and =ARRAY_CONSTRAIN(VSTACK(SEQUENCE(B1),SEQUENCE(2)),4,1). When it happens on setCellContents(B1, 2) the engine is left inconsistent (B1 holds 2, A1 still shows the values for B1 = 1).

Cause: vstackArraySize/hstackArraySize (and the ARRAY case of ArraySizePredictor) add up sub-sizes without checking isRef, so an element of unknown size counts as 1×1 and the predicted array is smaller than the evaluated one; ArrayValue.resize then throws. Wrapping the stack in a scalar function avoids it because the prediction is scalar.

Expected: when any element's size is unknown, the stack should predict ArraySize.error() (scalar fallback), as SEQUENCE itself does.

Reproduced on develop at c920375 (the merge-base of #1774; develop has had no src/ changes since). Unrelated to #1774, except that its runtime guard now returns #VALUE! when the evaluated stack also exceeds maxRows.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions