Skip to content

calc: a spill reference passes on an error held by its anchor (#3952) - #4115

Open
jayzed80 wants to merge 1 commit into
storytold:mainfrom
jayzed80:fix/spill-ref-error-3952
Open

jayzed80 wants to merge 1 commit into
storytold:mainfrom
jayzed80:fix/spill-ref-error-3952

Conversation

@jayzed80

Copy link
Copy Markdown

Fixes #3952

Root cause

crates/calc/src/eval.rs, unary(), the UnOp::Spill branch: when no spill range is registered for a single-cell anchor, it returned #REF! without looking at the anchor's own value. So =SUM(A1#) with A1 =1/0 gave #REF! instead of #DIV/0!.

Fix

When no spill range exists, read the anchor's value. If it is an error, return that error (#DIV/0!, #N/A, or #SPILL! for a blocked spill). Otherwise keep #REF! (ordinary scalar anchor). Successful spills are unchanged.

Tests

New spill_reference_passes_on_an_anchor_error in crates/calc/src/tests.rs covers =1/0, =NA(), scalar 7 (still #REF!), blocked SEQUENCE(2) (#SPILL!) and unblocked (3). Two existing assertions that encoded the old #REF! for a blocked spill now expect #SPILL!, as the issue reports for Excel.

With the fix reverted, cargo test -p gridcraft-calc spill gave: 24 passed; 3 failed (spill_reference_passes_on_an_anchor_error: left Error(Ref), right Error(Div0); spill_range_operator; formulas_reading_an_array_that_loses_a_spill_conflict_read_spill_errors). With the fix: all 126 calc tests pass.

Checks run

  • cargo test -p gridcraft-calc -j 4: 126 passed, 0 failed
  • cargo clippy -p gridcraft-calc --all-targets -j 4 -- -D warnings: clean
  • cargo fmt -p gridcraft-calc -- --check: clean

Not run

cargo xtask ci (wasm, layers, full workspace tests), other crates' tests, and a comparison against native Excel.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c0ee120 and df60ec3.

Files selected for processing: 2

  • crates/calc/src/eval.rs
  • crates/calc/src/tests.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spill references replace anchor errors with #REF! instead of propagating the original error

1 participant