Repository navigation
Spec + plan 0010: gather spill-aware interim references - #362
Merged
Merged
Conversation
/Gather only produces a good LET when the calculation was built dynamically from the start. When an interim step spills and the author references the spilled cells individually, the spill children come out as unrelated cell-reference inputs instead of slices of the array. The spec adds spill geometry to ICellSource (GetSpill replacing the HasSpill bool), classifies every reference against the spill it lands in, and rewrites it as a named slice binding over the anchor's binding. The slice ladder prefers the simplest expression: positional INDEX for single cells, edge-relative signed TAKE for flush bands, TAKE(DROP(...)) for interior blocks. Single-cell is checked before whole-array so a range that is simultaneously one cell and the whole spill takes the scalar path — a 1x1 array is not a scalar. Also covers two pre-existing defects in the same area: a spill child emitting B1# as its RHS (invalid on a non-anchor), and a scalar ref to a spilling anchor being silently widened to the whole array. The plan sequences eight PRs, front-loading a COM spike and a pure, unwired slice generator so PR 3 is a tracer bullet. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
taglotacks
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Docs only — no code changes. Adds
specs/0010-gather-spill-aware-references.mdandplans/0010-gather-spill-aware-references.md.Parent issue: #352 (children #353-#360).
What it covers
/Gatheronly produces a good LET when the calculation was built dynamically from the start. When an interim step spills and the author references the spilled cells individually — a two-capture REGEXEXTRACT, then reading each value separately — the spill children come out as unrelated cell-reference inputs.The spec adds spill geometry to
ICellSource(GetSpillreplacing theHasSpillbool), classifies every reference against the spill it lands in, and rewrites it as a named slice binding over the anchor's binding:The slice ladder prefers the simplest expression — positional INDEX for single cells, edge-relative signed TAKE for flush bands (
TAKE(arr,,-1)for the last column, not a counted CHOOSECOLS), TAKE(DROP(...)) for interior blocks.Two pre-existing defects folded in
B1#as its RHS, which is#REF!on a non-anchor — gather can currently produce a LET that does not evaluate. Contingent on the PR 1 spike (see below).=A1*2) is silently widened to the whole array. CorrectlyINDEX(arr,1,1).Worth a look on review
The spec's Problem section rests on an unverified assumption. It asserts spill children report
HasFormulafalse. If the spike in PR 1 (#353) finds otherwise, today's failure mode is a duplicated step rather than a stray input, and the "brokenB1#" claim is withdrawn. The design holds either way — only the problem statement and PR 3's regression tests differ. PR 1 is scoped to settle this and amend the spec before anything depends on it.Rule ordering carries the 1x1 guarantee. Single-cell is checked before whole-array, so a range that is simultaneously one cell and the whole spill (
A1:A1on a 1x1 spill) takes the scalar path. Getting this backwards would hand downstream steps a 1x1 array, which is not a scalar and collapses SEQUENCE/REGEXEXTRACT. A defensive@prefix was considered and rejected in Out of Scope — it would be redundant againstINDEXand would mask exactly this class of generator bug.Deliberately out of scope
Fill-down blocks (
C2:C10each=B2*2) still promote to a single range input rather than becoming a MAP — the other half of "not built dynamically", recorded with reasoning for a later spec. Also legacy CSE arrays, implicit intersection, and shape-robust slice expressions.