Skip to content

engine: keep AutoFill text series from panicking or wrapping on i64 overflow - #1360

Merged
aiongg merged 1 commit into
storytold:mainfrom
midasmatterhorn:fix/autofill-textnum-overflow
Oct 22, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
midasmatterhorn:fix/autofill-textnum-overflow

Conversation

@midasmatterhorn

Copy link
Copy Markdown
Contributor

AutoFill of a text series whose numbers sit near i64::MAX (e.g. X 0, X 9223372036854775807) panicked with attempt to add with overflow in debug and silently wrapped to a wrong value in release, because the detected step is i64::MAX and Pattern::value computed base + step * k * sign and n.abs() with unchecked integer arithmetic on input-derived numbers.

The Pattern::TextNum arm now uses checked_mul/checked_add/checked_sub/checked_abs; when the series would overflow it yields None, the existing "can't extend this series" fallback already used by month series, so the cell keeps its source value instead of panicking or writing a wrapped number. Regression test text_series_near_i64_max_neither_wraps_nor_panics in crates/engine/src/fill.rs sets up the two-cell source, runs edit.autoFill, and asserts the overflowing target keeps X 0; it failed with the overflow panic before the fix and passes after. Quarter suffixes (Qtr3, Quarter 3) now go through the same checked path, and all existing fill and fill-series tests still pass.

Partially addresses #1307 (finding 4, AutoFill overflow). Targeted tests green locally; cargo xtask ci left to the project runners.

aiongg added a commit to aiongg/gridcraft that referenced this pull request Oct 22, 2026
…the source in a corner (whole rows into whole columns aborted the app)

crates/engine/src/fill.rs: kept both tests (storytold#1360 and storytold#2005).
@aiongg
aiongg merged commit e9479d2 into storytold:main Oct 22, 2026
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.

2 participants